I was looking for a solution to this problem, and I just became old-fashioned. I also wanted to be able to find my hideText () method from other views in my application.
, "showmeState" hideText(), showText() , . , , render initialize, .
var View = Backbone.View.extend({
events: {
'click': 'toggleContent'
},
showmeState: true,
toggleContent: function(){
if (this.showmeState === false) {
this.showText();
} else {
this.hideText();
}
},
hideText: function() {
this.$el.find('p').hide();
this.showmeState = false;
},
showText: function() {
this.$el.find('p').show();
this.showmeState = true;
}
});
var view = new View();