Support options.separator and external jQuery
- if
select2.options.separatoris used, then act accordingly - if angular is loaded with jQlite (probably 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 1/ On my project loading jQuery before angular breaks other plugins because jQlite is not 100% compatible with all versions of jQuery (above all being event objects that might be very different in some instances) 2/ On my project, replacing jQlite by jQuery is forbidden
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 entire theory defeats the purpose of loading jquery at all. On Aug 3, 2014 10:28 AM, "Quentin Raynaud" [email protected] wrote:
@ProLoser https://github.com/ProLoser: there are multiple reasons to do so 1/ On my project loading jQuery before angular breaks other plugins because jQlite is not 100% compatible with all versions of jQuery (above all being event objects that might be very different in some instances) 2/ On my project, replacing jQlite by jQuery is forbidden
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.
— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-select2/pull/213#issuecomment-50993412.
@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 considering jquery is a superset of jqlite. On Aug 3, 2014 12:23 PM, "Quentin Raynaud" [email protected] wrote:
@ProLoser https://github.com/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.
— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-select2/pull/213#issuecomment-50996597.
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 On Aug 3, 2014 12:30 PM, "Quentin Raynaud" [email protected] wrote:
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.
— Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-select2/pull/213#issuecomment-50996832.
@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
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).
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 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.
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.
What I do know at least is that replacing jqlite by jquery in angular breaks some of the angular directives I'm using.
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 :
Or you can fix them with PRs. Even more helpful ! :+1:
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:
- the app would entirely use the fastest library between the two: jqLite
- jQuery would be used explicitly only where it is absolutely necessary, using $(angular.element(my_elt)).
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…