Skip to content

Instantly share code, notes, and snippets.

@webberig
Last active August 29, 2015 14:14
Show Gist options
  • Save webberig/b3b7ef12b8b960e934dc to your computer and use it in GitHub Desktop.
Save webberig/b3b7ef12b8b960e934dc to your computer and use it in GitHub Desktop.
Combine the power of a Backbone view with the simplicity of a jQuery plugin
(function($, Backbone){
var MyPluginView = Backbone.View.extend({
initialize: function(options) {
},
render: function() {
},
events: {
}
});
$.fn.myPlugin = function(options) {
this.each(function() {
var $this = $(this),
view = new MyPluginView({
el: this
});
view.render();
$this.data("view", view);
});
return this;
};
})(jQuery, Backbone);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment