Comments (3)
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);
}
}
}
from backbone.stickit.
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 [email protected] 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
#301 (comment)
.
Kartik*Python | Django | AngularJS Developer *
[image: Skype] kdbusiness90 [email protected] |
[email protected]
from backbone.stickit.
@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
}
}
});
from backbone.stickit.
Related Issues (20)
- Support falsy values in classes binding HOT 3
- [Suggestion] "name=" selector HOT 5
- Change Event Fires Twice for Number Input Type HOT 3
- events: ["keyup"] in ie8 HOT 1
- Using equality operator instead of identity operator for select field HOT 2
- Confusing `updateModel` name HOT 4
- Problems with defaultOption as a function, returning false
- Make 'updateModel' supporting Promise? HOT 3
- Make compatible with Lodash v4 HOT 2
- IE7 input change events
- The bindings crashed in IE11 and Edge checkbox
- Dependent select HOT 1
- Sorting select options
- bblatest branch / listenTo refactor question
- Deselecting multpile checkboxes don't run validation.
- Is this project still alive? HOT 3
- Maintainer Needed HOT 1
- Multiple DOM elements with matching ID's - is this legal? HOT 2
- Loss of context in onGet() function HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone.stickit.