EvanOxfeld / angular-selectize.js

Angular Selectize directive for a hybrid textbox + <select> box. Supports ngOptions and two-way bindings.
MIT License
34 stars 16 forks source link

Model not initializing correctly in some scenarios #19

Closed stgeorge closed 10 years ago

stgeorge commented 10 years ago

I ran into an issue where angular was populating the options and triggering a model update as well, which then went into scheduleUpdate, and the first time it initializes but eats the request that sent it there in the first place. I was using multiple select boxes with dynamically generated dropdown contents (using filtered expression) so not sure if that's related.

So I removed the:

modelUpdate = optionsUpdate = false;
return;

To allow it to fall through and process the request after initializing and that seemed to work but I'm not sure what the original purpose this check was trying to fix.

EvanOxfeld commented 10 years ago

scheduleUpdate skips the model update if the selectize component is still initializing to avoid the selectize object being in an unknown state. Perhaps avoiding one timing issue has caused another.

Does it solve your scenario if we remove the modelUpdate = optionsUpdate = false; line and just return?

stgeorge commented 10 years ago

I tried it with just the return and it seems to function correctly in my app (using single selection mode).

EvanOxfeld commented 10 years ago

In 1.4.3 the directive doesn't reset the modelUpdate and optionsUpdate flags if selectize is uninitialized.

I think this issue is resolved, but if you run into problems again we can reopen it.