Store DOM object\'s events for later reuse, aka temporary unbind (jqzoom)


/ Published in: jQuery
Save to your folder(s)

I needed to temporarily unbind jqZoom plugin events from a DOM-element and store them for later use. That's what worked for me. Any comments and suggestions would be much appreciated!


Copy this code and paste it in your HTML
  1. var zoomEvents = $.extend(true,{},jqzoom.data('events')); //deep copy of an event object
  2.  
  3. jqzoom.trigger('mouseleave'); // this just emulates mouseleave event in order to hide zoom box
  4. jqzoom.unbind();
  5.  
  6. for (i in zoomEvents) {
  7. var evt = zoomEvents[i];
  8. for (k in evt) {
  9. jqzoom.bind(evt[k].type, evt[k].handler)
  10. }
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.