-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support optgroup #23
Comments
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 |
@derekhardison - Another solution might be for stickit to handle another 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. |
@delambo looks nice. |
@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. |
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. |
I've overlooked the documentation or it is not supported-stickit does not like optgroups and will remove them from my select elements if they are in there!
Great stuff otherwise!
The text was updated successfully, but these errors were encountered: