Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Multiple Downloads #1428

Merged
merged 14 commits into from
Jan 15, 2020
4 changes: 2 additions & 2 deletions examples/lib/defaultHtmlStepUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
$step('img').show();
$stepAll('.load-spin').hide();
$step('.load').hide();

step.imgElement.src = (step.name == 'load-image') ? step.output.src : step.output;
var imgthumbnail = $step('.img-thumbnail').getDomElem();
for (let index = 0; index < step.linkElements.length; index++) {
Expand All @@ -308,7 +308,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
return output.split('/')[1].split(';')[0];
}

$stepAll('.download-btn').on('click', () => {
$stepAll('.download-btn').unbind().on('click', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to use .off('click') instead of unbind? unbind will remove all the event handlers but we only want the click event handler to be removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, did you find out why $stepAll is used here? This is a bit confusing. Does it work with just $step? If yes, then it would be better to use $step instead of $stepAll.

Wait, the error could be caused because of $stepAll. We want to add a download listener to the current step but $stepAll will add a listener to every step each time a new step is added. So every time a step is added, an extra listener will be added to the older steps. If I am not wrong then changing $stepAll to $step without unbind or off should fix everything.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing it to $step didn't work.
Isn't $stepAll derived from scopeSelectorAll which should basically mean to select all the instances of the element present inside the scope (i.e in the current step). By that shouldn't $stepAll refers to the all the elements in the current step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah! I guess I forgot myself. Lol. I was the one who added scopeQuery 😅.
Okay then your code should work fine. Will review again in a min.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I revert back to off(‘click) in this one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you should. Sorry for the late response.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


var element = document.createElement('a');
element.setAttribute('href', step.output);
Expand Down