-
Notifications
You must be signed in to change notification settings - Fork 443
Support options.separator and external jQuery #213
base: master
Are you sure you want to change the base?
Conversation
- if select2.options.separator is used, then act accordingly - if angular is loaded with jQlite (ptobably because jQuery was loaded after angular), keep things working
Closed #156 as this merge provides a better fix. |
@qraynaud you shouldn't be loading jquery in the wrong order to begin with |
@ProLoser: there are multiple reasons to do so I believe others might have issues related to this. If I do rebase this, is it likely it will be accepted? I remind you that the changes that I had to make to allow jQuery to be loaded after angular are VERY small. |
Loading jquery first causes AngularJS to use jquery instead of jqlite. Your
|
@ProLoser: I'm probably stupid but I don't understand why. Where are the cons of preventing angular from using jQuery but letting directives do so in a controlled and limited way? Why make angular use jQuery a required thing and not an optional thing if it's possible? What I do know at least is that replacing jqlite by jquery in angular breaks some of the angular directives I'm using. |
That should not happen unless you or they are doing something wrong
|
As I just said before, this is not true. Because jQuery is replacing the event objects, sometime some properties of the browser's event object are not copied over the the jquery object. jqlite does not do this and expose the browser event object directly. Some of the directives I'm using are requiring some attributes that are trimmed by jQuery but not jqlite. |
Open an issue on the AngularJS lib
|
@douglasduteil, I believe we need another point of view Douglas. Can you give us yours about this? I believed the angular-ui team spirit was to make ui components as independent from jQuery as possible (and to even remove jquery dependency as much as possible). I don't understand why making jquery in angular optional would be a bad thing at all. This won't change how it works when jquery is loaded before angular but it will also work when it is loaded after. This seems like a good thing to me. This is allowing devs to have more flexible webapps at no cost. In my case, it would allow me to load jquery + select2 libs only for admins while trimming all this from my app for normal users that won't ever have access to select2 forms in my app (I can load jquery on demand because I don't have other components requiring jQuery) |
Hi @qraynaud
True for me, however this https://github.com/angular-ui/ui-select2 directive is depending on jQuery. If you're looking for a pure AngularJS version of it (working with or without jQurey) check https://github.com/angular-ui/ui-select
I don't have special opinion about that. Just feels like having AngularJS handling the jQuery switch is enough to freely plugin components made with jQuery.
I'm more concern about this. I find the problem is those other directives that aren't jQuery compatible... I think you should open a issue to them saying some thing like :
« You Angular support is bad and You Should Feel Bad »
Or you can fix them with PRs. Even more helpful ! 👍 |
I'm also interested on the question: is loading jQuery after Angular really a bad thing? Performance-wise, it seems a very good approach as jqLite is faster than jQuery:
About ui-select2, maybe looking at angular-ui/ui-select would be a good alternative. In any case, I don't see why this PR would not be merged… |
select2.options.separator
is used, then act accordingly