I need to run some code on focus and blur events on elements that were injected into the DOM after page load. So I am using Zepto's on
(Zepto's on link) to run the code but it doesn't work for me.
Here is my jsfiddle in which I am trying to make it work - http://jsfiddle.net/ashfame/zR2xL/
Your on declaration was a little off in the original JSFiddle. When you use the .live()
"version" of .on()
you select the document with Zepto (because, I believe, that's what the .live()
function does behind the scenes) then apply the .on()
method and pass it the parameters event
, selector
, and function
. It looks something like this:
$(document).on(event, selector, function);
Check out this JSFiddle that I modified a bit from the one you posted in the comments.
The changes I made were:
console.log()
to stop errors from being throwndocument.write
to a $('body').append()
Hope that helps!