Skip to content

Commit

Permalink
Changed bind/unbind and live with on/off methods
Browse files Browse the repository at this point in the history
As of jQuery 1.7, the .on() and .off() methods are preferred to attach and remove event handlers on elements.
  • Loading branch information
adiospace committed Feb 16, 2012
1 parent 5350977 commit 421516e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions jquery.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
opacity: options.opacity
});
if(options.escapeClose) {
$(document).bind('keydown.modal', function(event) {
$(document).on('keydown.modal', function(event) {
if(event.which == 27) {$.fn.modal.close();}
});
}
Expand Down Expand Up @@ -92,7 +92,7 @@
current_modal.elm.trigger($.fn.modal.CLOSE, [current_modal]);
current_modal = null;

$(document).unbind('keydown.modal');
$(document).off('keydown.modal');
};

$.fn.modal.resize = function() {
Expand All @@ -109,7 +109,7 @@
$('<div/>')
.html(html)
.appendTo('body')
.bind('modal:close', function(event, modal) { modal.elm.remove(); })
.on('modal:close', function(event, modal) { modal.elm.remove(); })
.modal();
});
}
Expand All @@ -127,7 +127,7 @@
};

// Automatically bind links with rel="modal:close" to, well, close the modal.
$('a[rel="modal:open"]').live('click', open_modal_from_link);
$('a[rel="modal:close"]').live('click', $.fn.modal.close);
$(document).on('click', 'a[rel="modal:open"]', open_modal_from_link);
$(document).on('click', 'a[rel="modal:close"]', $.fn.modal.close);

})(jQuery);

0 comments on commit 421516e

Please sign in to comment.