-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngJq is not picking the jQuery version #11647
Comments
@mboudreau maybe you'll have an idea ? |
@cexbrayat Yes, I do. Essentially, it comes down to event flow based on the initialization. In this case, Angular is being loaded and initialized in the head. ng-jq gets called as soon as angular initializes since Angular needs angular.element to be available from the get-go. When debugging the code, when it hits the jq() function within Angular, I printed out the 'document' that's current returned and I got this:
As you'll notice, there's no body in there. I'm not sure why this is happening since I would imagine that the body would be present in the html itself. It seems like javascript doesn't have access to it just yet... Either way, if you want to fix this issue, you can either remove the angular.js library from within the head and place it within the body underneath your bit of templating code, or you can simply move the ng-app, ng-jq and ng-controller attributes to be part of the html tag instead of the body. This way, when angular searches for the ng-jq tag, it will be present no matter what. Cheers. |
Since the DOM is being built while parsing the HTML from top to bottom,it is epected that while executing a script in the In addition to @mboudreau's suggestion (and taking into account that |
Thank you both for your answers. I was not really worried about my own case (that was just a simple plunkr for an upcoming blog post on the 1.4 release), as I was that there might be a real problem. Your explanations make perfect sense, but it's slightly surprising, I think other people are gonna be bite by this... I'll close the issue, but maybe this kind of thing should be documented, or even better, |
Well, to be fair, this is not the position of ngJq that matters, but if On Mon, Apr 20, 2015, 6:03 PM Cédric Exbrayat [email protected]
|
@mboudreau, not really. JavaScript can parse the DOM, but only the part of the DOM that has already been created by the time it is executed. The DOM is constructed incrementally as the HTML is being parsed by the browser, so it is indeed a matter of position. Ideally, Maybe a short mention in the docs would be in place. |
I was trying to set up a simple example for
ngJq
and it is not picking the jQuery version that I aliased toMaybe that's not how it is supposed to work, but when debugging the source code in rc0, it appears that the
ng-jq
attribute is never picked up by the querySelector in https://github.com/angular/angular.js/blob/master/src/Angular.js#L998I may be missing something obvious, but I can't see what...
I reproduced in this plunkr
The text was updated successfully, but these errors were encountered: