axel-zarate / js-custom-select

Custom auto-complete select box for AngularJS and Bootstrap
MIT License
68 stars 59 forks source link

The options change,but can not render again. #11

Closed shawcon closed 9 years ago

shawcon commented 9 years ago

the directive works perfectly when the page load complete. But when I have two cascade selectors,the first one selected,and the options of the second one changed,but the directive can not render the options again,keep the options loaded first time.

BTW,how to integrate the directive with bootstrap class form-control.

nstohler commented 9 years ago

I have the same problem: When I want to populate the select with some data that comes from the server, it does not show up at all. Also, adding some items later to the array of items does not display those unless one types something into the search box.

Demo here (Complex objects: initialized from code (states) works, but when you click the "add some items" button, those items aren't being displayed then (only after searching for something)): http://plnkr.co/edit/BjcmUfdzca3VG1CV83gU?p=preview

axel-zarate commented 9 years ago

This is because of the lazy evaluation of the filter function. It is a good idea to limit the filtering when the search is performed on the server, but for local scenarios it causes problems like this one. For that reason, I added an async option to let the directive know that we're dealing with an async (remote) filter. If not set explicitly, the filtering is going to be performed every time the dropdown is open, pulling any new item that may have been after the last time it was open.

Fixed in commit 2e3c744c49fa0e84918fcc3bbe50245abee04d41.