Comments (6)
userBindings:
'#username': 'username'
render: ->
if loggedin
@stickit @model, userBindings
in js:
userBindings: {
'#username': 'username'
},
render: function() {
if (loggedin) {
this.stickit(this.model, userBindings);
}
}
from backbone.stickit.
I second @andriijas' approach - create two bindings objects for the different states.
from backbone.stickit.
on second thought here though, I wonder why the whole thing should bork if one field in your bindings map doesn't exist? I almost feel like it should just ignore bindings that don't exist instead of stopping the train. that would decrease the need for creating logic to handle multiple bindings as in the scenario described... no?
from backbone.stickit.
I'm not quite sure if I understand your problem. I setup the following fiddle with a selector to an element that doesn't exist and it seems to work fine:
Can you modify this fiddle to show me what you are seeing?
from backbone.stickit.
I ran into this issue recently. The problem is that I was using lodash and not underscore. In the stickit function there is an "each" loop that returns false if the selector does not find an element. It appears lodash's "each" does not support early breaking of the loop while underscore does. I switched to underscore to fix the issue. Is the "return false" intended to be an early break or is it meant to abandon applying the bindings?
I did read that underscore should not support early breaking in each loops but it seems it does in version 1.4.4: jashkenas/underscore#960.
And lodash says it does not support early breaking as well: lodash/lodash#99.
That leaves me a little confused but the switch to underscore does seem to address my problem.
from backbone.stickit.
Removed false from that return statement on master.
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
- bind the model with backbone variable HOT 3
- 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.