wangshijun / angular-bootstrap-chosen

angular-bootstrap-chosen
MIT License
6 stars 4 forks source link

element.chosen not a function #1

Open asheshambasta opened 9 years ago

asheshambasta commented 9 years ago

TypeError: undefined is not a function at initOrUpdate (http://0.0.0.0:8888/bower_components/angular-chosen-localytics/chosen.js:58:30)

Right off the bat.

peduarte commented 9 years ago

Same.

Dervisevic commented 9 years ago

I struggled with this for so long, even went to try https://github.com/adityasharat/angular-chosen and got the SAME ERROR :angry:

I copied the script files of this other repos gh-page and it suddenly worked, i was confused so i played around with it. And the issue i had was I was loading angular before jquery and chosen. Simple moving the script tag below those 2 but before angular-chosen fixed it. Hope it solves it for anyone else having this issue. The documentation should be more clear on it.

adityasharat commented 9 years ago

If you load angular before jquery, the element you get in the linker of the directive is a jqLite element and not a jQuery element. So it won't have the chosen function on it.

If you load jQuery before angular, angular will use jQuery instead of jqLite.

raphaklaus commented 9 years ago

Why jQuery dependency is mandatory? Jqlite or pure Javascript would not be enough?