fe-jquery-plugin

0.0.10 • Public • Published

Jquery Plugin Base Class

Simple base class that sets up :

- plugin name
- instance reference as data attr on element
- plugin method exec from element via string
- destruction life cycle.

Usage

Creating a plugin

...
plugin = require 'fe-jquery-plugin'

class Foo extends plugin

	@defaults:
		activeClass: 'active'

	initialize: (@options)->
		super(@options)
		# rest of your per instance initialisation here

	bar: ->
		@destroy()
		@element.remove()

Foo.register()
...

Using it

Attach it to an element as per usual jquery shenanigans.

...
$('#foo').Foo({activeClass: 'buwahaha' });
...

But now:

...
$('#foo').Foo('destroy');
...

Also, the plugin instance is available on the object:

...
var instance = $('#foo').data('Foo');
console.log(instance);
// => Foo

Testing

tests are outlined, and require fullfilling.

Readme

Keywords

Package Sidebar

Install

npm i fe-jquery-plugin

Weekly Downloads

3

Version

0.0.10

License

ISC

Last publish

Collaborators

  • fusion-npm