Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ng-jq only works on html tag #11779

Closed
TheBelgarion opened this issue Apr 30, 2015 · 4 comments
Closed

ng-jq only works on html tag #11779

TheBelgarion opened this issue Apr 30, 2015 · 4 comments

Comments

@TheBelgarion
Copy link

I tried the new tag 'ng-jq' to disable trying to use my very old jQuery lib

(not working) (working)

In my case I tried to improve a small module in a very old Joomla page so changing the layout template is not really a nice way to do it - would be better if I could use ng-jq on the app tag too)

AT least the description stated it not madatory to do it in the tag

tried with: 1.4.0-rc.1

@kentcdodds
Copy link

I'm guessing this is your issue. Compare this jsbin (not working) to this jsbin (working). The difference is where angular is being loaded. I'm guessing that you're placing the angular script on the page BEFORE the element with the ng-jq tag. I'm guessing that the issue is that at the time angular loads, it will look in the DOM and try to find ng-jq. Because that part of the DOM hasn't been loaded yet, angular doesn't find it.

So your solution is to make sure that the element with ng-jq appears BEFORE the script tag that loads angular.

Perhaps I'll make a PR to update the docs to point out this issue. Good luck!

kentcdodds pushed a commit to kentcdodds/angular.js that referenced this issue Apr 30, 2015
change docs for ngJq so it mentions that the placement of the directive is important with regards to the angular script.

Closes angular#11779
@caitp
Copy link
Contributor

caitp commented Apr 30, 2015

That's right. Unfortunately this info needs to be known before the document is ready, so it needs to be an early element

@kentcdodds
Copy link

Ah, and another alternative would be to simply place the jQuery script AFTER the angular script. You wouldn't need the ng-jq script on the page at all for this solution.

@TheBelgarion
Copy link
Author

Ha, yes that makes sense, was somehow thinking it inits after domready, but guess it need to run earlier for all the gimmicks ..

@kentcdodds I think there was some talk why loading jQuery after angularJS doesnt work in all cases
e.g. some code simple uses

if (!jQuery) {...} else {jQlite}

issue relates to #11647 ( just found that now)

thx!

caitp pushed a commit that referenced this issue May 1, 2015
change docs for ngJq so it mentions that the placement of the directive is important with regards to the angular script.

Closes #11779
Closes #11780
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
change docs for ngJq so it mentions that the placement of the directive is important with regards to the angular script.

Closes angular#11779
Closes angular#11780
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants