Open kdbusiness90 opened 8 years ago
You would rather control this in your View. Something like:
bindings: {
'#uRepeateverybyweek': {
observe: 'uRepeateverybyweek',
onGet: function(val) {
var displayMode = val ? 'inline-block' : 'none';
this.$('#uRepeateverybyweek').css('display', displayMode);
}
}
}
Hi David,
i have tried above code with below HTML but is giving me.
Resultant:
On Sat, Dec 26, 2015 at 9:45 PM, David Skx notifications@github.com wrote:
You would rather control this in your View. Something like:
bindings: { '#uRepeateverybyweek': { observe: 'uRepeateverybyweek', onGet: function(val) { var displayMode = val ? 'inline-block' : 'none';
this.$('#uRepeateverybyweek').css('display', displayMode); } }
}
— Reply to this email directly or view it on GitHub https://github.com/NYTimes/backbone.stickit/issues/301#issuecomment-167338589 .
KartikPython | Django | AngularJS Developer [image: Skype] kdbusiness90 kdbusiness90@gmail.com | kdbusiness90@gmail.com
@kdbusiness90 you can remove your if
statement. Also a small note, this is highly dependent on how you supply your model to your template. Marionette standardizes this heavily, and underscore
templates really don't scale as well as something like Handlebars
. All that being said, I wouldn't pass your entire model instance into the view, rather a serialized representation. Also: stickit
has built-in capabilities for hiding / showing elements based on model attributes.
var MyView = Backbone.View.extend({
template: _.template('#my_template'),
render(){
this.$el.html(this.template(this.model.toJSON())); // Only pass in serialized Model.
return this;
},
bindings: {
'#uRepeateverybyweek': {
observe: 'uRepeateverybyweek',
update: false, // Don't try to update this element, only make it
visible(val, options){ return val } // visible depending on `uRepeateverybyweek` attribute
}
}
});
Hi All,
How do i bind the model with backbone variable like
In Html:
elements.attributes.uRepeateverybyweek is not working ? with backbone.stickit