Comment

Comment by npongracic

I think this is great, i was also thinking of replacing jquery functionality in some of my scripts with native methods and this helps me alot.

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)

parent npongracic 12 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton