開発メモ

開発用のメモです。

JQuery delegate/live/bindとついになる関数を on/off に転送する

<script>
$(document).ready(function(){
   $.fn.delegate = function(selector, action, callback) {
       $(this).on(action, selector, callback);
   }
   $.fn.undelegate = function(selector, action) {
       $(this).off(action, selector);
   }
   
   $.fn.live = function(action, callback) {
       $(document).on(action, $(this), callback);
   }
   $.fn.die = function(action) {
       $(document).off(action, $(this));
   }
   
   $.fn.bind = function(action, callback) {
       $(this).on(action, callback);
   }
   $.fn.unbind = function(action) {
       $(this).off(action);
   }
});
</script>
Twitter: @asahina_alice