Comments (5)
Hello!
I forked your wonderful project, and tweaked it so it wouldn't wipe out the optgroup(s). Basically, check if the option already exists before creating it. If the option exists, just perform your actions on the existing one instead of a new one. I'd prefer to use the main repository if possible, so if this fix is implemented I'll revert back to it!
https://github.com/derekhardison/backbone.stickit/commit/62a1f7bcc6e5f5b552dcdf489038ebef559085fe
Derek
from backbone.stickit.
@derekhardison - Another solution might be for stickit to handle another collection
data structure. An optgroup could be represented as an ordered hash of labels that map to collections. Since JavaScript doesn't have an ordered hash, an addtional key could be used to map the ordered list of labels. For example:
bindings: {
modelAttr: 'character',
'select#tv-characters': {
collection: function() {
return {
'opt_labels': ['Looney Tunes', 'Three Stooges'],
'Looney Tunes': [{id: 1, name: 'Bugs Bunny'}, {id: 2, name: 'Donald Duck'}],
'Three Stooges': [{id: 3, name : 'moe'}, {id: 4, name : 'larry'}, {id: 5, name : 'curly'}]
}
},
labelPath: 'name',
valuePath: 'id'
}
}
I'm going to sit on this one for a sec. I would love to get some feedback.
from backbone.stickit.
@delambo looks nice.
from backbone.stickit.
@delambo That's fine too, but only allowing it to be built by stickit makes template systems (such as handlebars) less useful if you're setting up simple static lists of options/optgroups. The ability to do it both ways would be nice.
from backbone.stickit.
This is in master. It will go out in the 0.6.1 release, soon.
@derekhardison - one of the major advantages of using stickit is that you don't need to wrestle with template language features or need to write a lot of javascript/configuration in your templates (if any at all - I rarely do!). I find this strategy to be less error prone, easier to configure, and it generally makes developers happier. I'm going to delay support for pre-configured/built lists.
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.