Skip to content

Instantly share code, notes, and snippets.

@MartijnR
Last active December 10, 2015 07:08
Show Gist options
  • Save MartijnR/4398882 to your computer and use it in GitHub Desktop.
Save MartijnR/4398882 to your computer and use it in GitHub Desktop.
jQuery plugin
(function($) {
"use strict";
var MyWidget = function(element, options) {
this.init();
};
GeopointWidget.prototype = {
constructor: GeopointWidget,
init: function(){}
};
$.fn.myWidget = function(option) {
return this.each(function() {
var $this = $(this),
data = $(this).data('mywidget'),
options = typeof option == 'object' && option;
if (!data){
$this.data('mywidget', (data = new myWidget(this, options)));
}
if (typeof option == 'string') {
data[option]();
}
});
};
$.fn.geopointWidget.Constructor = MyWidget;
})(window.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment