Skip to content

Using bind() method which is now deprecated in jQuery #2806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davidjgoss opened this issue Jun 13, 2016 · 0 comments · Fixed by #2894
Closed

Using bind() method which is now deprecated in jQuery #2806

davidjgoss opened this issue Jun 13, 2016 · 0 comments · Fixed by #2894

Comments

@davidjgoss
Copy link

The bind() and unbind() methods which angular.element implements from the jQuery API are now deprecated in jQuery. In the new slim build of jQuery 3.0 these methods are removed from the code for the first time.

This means that if you use the new version of jQuery along with Angular and UI Router, Angular will gracefully let jQuery take over from angular.element but bind() and unbind() won't be available when UI Router tries to use them for the $StateRefDirective and $StateRefDynamicDirective link functions, and functionality will break. See this plunkr (and watch the console for errors):
http://plnkr.co/edit/b3pOQKRmuJRS7RyLbDP8?p=preview

(When you select a different state, it won't intercept the route change and a request will go off to the server, wrongly, because it wasn't able to set the event handler up.)

Replacing the (only 2!) usages of bind() and unbind() with on() and off() respectively should fix compatibility with the newest jQuery whilst maintaining compatibility with angular.element.

More than happy to do a PR for this, but will just wait for the nod from a project member.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants