Skip to content

Instantly share code, notes, and snippets.

@kswedberg
Last active December 19, 2015 22:48
Show Gist options
  • Save kswedberg/6029710 to your computer and use it in GitHub Desktop.
Save kswedberg/6029710 to your computer and use it in GitHub Desktop.

Old

Plugins that need to use a selector should have the caller pass in the selector as part of the plugin's arguments during initialization.

New

Plugins that need to use a selector string within their plugin can require it as a parameter of the method. For example, a "foo" plugin could be written as $.fn.foo = function( selector, options ) { /* plugin code goes here */ }, and the person using the plugin would write $( "div.bar" ).foo( "div.bar", {dog: "bark"} ) with the "div.bar" selector repeated as the first argument of .foo().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment