Reply
Highlighted
Visitor
Posts: 1
Registered: ‎01-31-2017

Tagging Modals / Popups

Hello, 

On Screwfix.com we have a popup that shows when a customer clicks the delivery or Click and collect buttons. 

 

When an add to basket button is clicked JS kicks in and shows the pop up for that product, I want to be able to tag the buttons within this modal, however, when i create a jQuery onHandler it does not fire when that class is clicked.... is this because the markup is not in the DOM until the div is clicked and JS shows the modal?

 

How can I tag the different elements?

 

Many Thanks

James 

Reply
0 Kudos
Community Manager
Posts: 748
Registered: ‎08-26-2015

Re: Tagging Modals / Popups

Hello @jhooper. Great question. Perhaps this post can help? 

 

Let me know! 

 

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.
Reply
0 Kudos
Frequent Contributor
Posts: 96
Registered: ‎11-15-2015

Re: Tagging Modals / Popups

Hello @jhooper

I would recommend to go ahead with below JS code to able to tag the required buttons within your modal. Sometime your code will execute before DOM is ready.

addEvent(window, 'load', function(e) {
var input = document.body;
addEvent(input, 'mousedown', function(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (target.parentNode.id === 'abc') {
}
});
});

Hope it helps! Kindly let me know if you need any clarifications on this. Thanks!