One question though, what is the pure javascript equivalent of $(document).on('click', '.selector', function() { // do something });
This is the new jquery .live() replacement and i need it because normal events stop working after async postbacks (eg. from an asp.net UpdatePanel).
Will this code do the trick if i attach it to the document element? Also i need IE8+ support :)
function addEventListener(el, eventName, handler) { if (el.addEventListener) el.addEventListener(eventName, handler) else el.attachEvent('on' + eventName, handler) }
addEventListener(el, eventName, handler)
One question though, what is the pure javascript equivalent of $(document).on('click', '.selector', function() { // do something });
This is the new jquery .live() replacement and i need it because normal events stop working after async postbacks (eg. from an asp.net UpdatePanel).
Will this code do the trick if i attach it to the document element? Also i need IE8+ support :)
function addEventListener(el, eventName, handler) { if (el.addEventListener) el.addEventListener(eventName, handler) else el.attachEvent('on' + eventName, handler) }
addEventListener(el, eventName, handler)