I often enjoyed live success in my plugins as a regular option. Here is a trivial example that adds a warning to the elements that were clicked:
$.fn.clickAlert = function(settings) { settings = $.extend({live: false}, settings); function clickAlertFn() { alert('Clicked!'); } if (settings.live) { return this.live('click', clickAlertFn); } else { return this.click(clickAlertFn); } };
In this example, everything that works fine with $ ('...'). live ('click', ... ') will work with $ (' ... '). clickAlert ({live: true});
One more thing, in most plugins you do something like this:
$.fn.foo = function() { return $(this).each(function() {
Unfortunately, using live inside each loop will not work.
source share