Remove and restore event handlers


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



Copy this code and paste it in your HTML
  1. function remove() {
  2. $('.elements').each(function() {
  3. if ($(this).data('events')) {
  4. $(this)
  5. .data('eventStore', eval($(this).data('events').toSource()))
  6. .unbind();
  7. }
  8. });
  9. }
  10.  
  11. function restore() {
  12. $('.elements').each(function() {
  13. var events = $(this).data('eventStore');
  14. if (events) {
  15. for (var type in events) {
  16. for (var num in events[type]) {
  17. $(this).bind(type, events[type][num].handler);
  18. }
  19. }
  20. }
  21. });
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.