Rich-text Reply
Highlighted

Existing events will be overwritten.

ShunsukeUrita a week ago

Existing events will be overwritten.

Existing jQuery events(e.g. click ) will be overwritten by Optimizely.

I think that it occurs because Optimizely's DOM overwrites the existing DOM.

this existing DOM bound to click event.

 

I temporarily using setTimeout function.

Does anyone have good solution?

 

thanks.

Re: Existing events will be overwritten.

Hi Shunsukeurita- I am going to submit a support ticket on your behalf to our support team.

Thanks,
Michelle Curtis
JasonDahlin a week ago
 

Re: Existing events will be overwritten.

@ShunsukeUrita,

It depends on what you are doing.

 

If you are using Optimizely to add a click event to an element that already has a click event, then both click events will fire.

 

If you are using Optimizely to replace an existing element (which may have a click event attached to it) with a new element, you will need to add the click event to the new element.

 

If you are using Optimizely to modify an element which gets a click event attached to it and the click event is not happening, then it is likely caused by the click event failing to recognize the element after it has been modified. (e.g., your site's code runs something like $('#someDiv .thisElement button').on('click',...) but you are changing the element so that the jQuery selector (or equivalent) no longer points to the element). If this is happening, either: 1- change the way you are altering the element so that the click event binding still works, or 2- change the click event binding to work with the new element's jQuery selector.

 

If none of the above accurately describe your scenario, please provide details.

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
Experimentation Hero

Re: Existing events will be overwritten.

@JasonDahlin
Thanks for your reply!

In detail, existing element which is attached click event is compiled by Babel(it is difficult to read this compiled code). This is why I can't rewrite on Optimizely.

> you will need to add the click event to the new element.
Do you have a any option(API, grobal object and so on) to attach existing event after Optimizely DOM was attached?