- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Why does jQuery's .on() function not work in Experimental JavaScript editor?
Why does jQuery's .on() function not work in Experimental JavaScript editor?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Hello,
I'm trying to fire a Custom Optimizely Event after a custom jQuery event has run so to do this, I'm trying to listen for the event like this
$form.on('ajax:success', function(e, d, s, x){ window.optimizely.push(['trackEvent', 'newsLetterError']); });
The editor is throwing a TypeError - $form.on is not a function.
Any ideas please?
Thanks,
Nick Middleweek
Re: Why does jQuery's .on() function not work in Experimental JavaScript editor?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Hi @nmiddleweek,
The Optimizely snippet uses jQuery version 1.6.4, but .on() was not introduced until 1.7
You can use .on() if you include jQuery 1.7.X on the page above the Optimizely snippet
See an example in Project Settings: JavaScript/jQuery along with the full list of 1.6.4 methods
Using the code provided in that article, @JDahlinANF also made bookmarklets to allow you to quickly retrieve Optimizely's jQuery methods as well as the jQuery methods on your page that are not included in Optimizley's version.
Hope that helps!