Rich-text Reply

Why does jQuery's .on() function not work in Experimental JavaScript editor?

nmiddleweek 11-02-15

Why does jQuery's .on() function not work in Experimental JavaScript editor?

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

 

Ehsan 11-02-15
 

Re: Why does jQuery's .on() function not work in Experimental JavaScript editor?

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, @nap0leon 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!

Optimizely