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

Rebinding causes issue with Knockout #49

Closed
ewassef opened this issue Jan 2, 2015 · 3 comments
Closed

Rebinding causes issue with Knockout #49

ewassef opened this issue Jan 2, 2015 · 3 comments
Labels

Comments

@ewassef
Copy link

ewassef commented Jan 2, 2015

When calling .imagepicker on a select box that is bound to knockout the first time everything works fine. When that select list is changed and the call is made again (as is recommended) the underlying select list seems to never receive the updates on when an item is selected. the thumbnail does highlight correctly though.

Is there a way to totally destroy the first instance and recreate it? the destroy method seems to leave some stuff behind.

Knockout is mentioned because it is more apparent with knockout. The scenario is items get added to the list from other dom events and would be added or removed from the master select list. The user would then get the option to pick from this master list. Things work great on the first time around but stop once anything is changed on the select list

@ewassef
Copy link
Author

ewassef commented Jan 2, 2015

ImagePicker.prototype.destroy = function () {
var option, _i, _len, _ref;
_ref = this.picker_options;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
option = _ref[_i];
option.destroy();
}
this.picker.remove();
//this.select.unbind("change"); //Removing this line resolves the issue
this.select.removeData("picker");
return this.select.show();
};

@rvera
Copy link
Owner

rvera commented Mar 31, 2015

Thanks for this @ewassed, can you provide a jsfiddle example with the issue?

You are probably not the only one seeing this and would love to fix it.

@rvera rvera added the bug label Sep 25, 2016
@rvera
Copy link
Owner

rvera commented Sep 25, 2016

Thanks for reporting this, came back to it a year later.

It's obvious to me now what was probably the issue this.select.unbind("change") was probably removing all listeners and instead of only the ones I added. Made a fix for this in the latest release.

@rvera rvera closed this as completed Sep 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants