Skip to content

Instantly share code, notes, and snippets.

@felipap
Created November 10, 2013 18:55
Show Gist options
  • Save felipap/7402240 to your computer and use it in GitHub Desktop.
Save felipap/7402240 to your computer and use it in GitHub Desktop.
The basic object I use to inherit most of my views in vempraruavem.org from.
var DefaultView = Backbone.View.extend({
btn: $("<div>"),
constructor: function () {
var self = this;
this.btn.click(function () { self.toggle(); });
Backbone.View.apply(this, arguments);
this.$el.on('click', '[data-action=exit]', function () { self.hide(); })
},
show: function () {
this.$el.fadeIn();
this.btn.addClass('active');
var self = this;
},
hide: function () {
this.$el.fadeOut();
this.btn.removeClass('active');
},
toggle: function () {
this.$el.fadeToggle();
this.btn.toggleClass('active');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment