Skip to content
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

Add automatic generation of select options to form view #84

Open
ccpowers opened this issue Jun 23, 2015 · 2 comments
Open

Add automatic generation of select options to form view #84

ccpowers opened this issue Jun 23, 2015 · 2 comments

Comments

@ccpowers
Copy link

Stickit works better with selects if you pass a selectOptions hash when creating the bindings:
http://nytimes.github.io/backbone.stickit/#selectoptions

Otherwise you need to add a data-stickit-bind-val attribute to the DOM and it doesn't always re-render correctly. A good way to solve this would be to add support for auto-generating the select options hash when the form view generates the other bindings.

@kentmw
Copy link
Contributor

kentmw commented Jan 14, 2016

This has to do these qualities of the select:

  • select
    • (recommended) specify selectOptions to have Stickit handle the rendering and option bindings of your select (see selectOptions)
    • if you choose to pre-render your select-options (not recommended) then there are two ways of configuring the bindings:
      • The "data-stickit-bind-val" attributes in the DOM. This allows for binding non-string values from a prerendered , assuming that you are using jQuery or a build of Zepto that includes the "data" module. "option[value]" attributes in the DOM (used if no data-stickit-bind-val is present) change event is used for handling

@kentmw kentmw reopened this Jan 14, 2016
@kentmw
Copy link
Contributor

kentmw commented Jan 14, 2016

This seems to be the biggest problem with non-string values in the form model. Using numbers in the form model and putting the "matching" values in the dom will cast them as strings and it won't match. Adding data-stickit-bind-val is what Katy did, but apparently re-rendering hit issues. Her pull request is an attempt to use the recommended "selectOptions" but still utilizing the DOM. Perhaps using the formView's "fields" attribute might be a way to auto-generate the options. But alas, all of these have issues with keeping and defining attributes of the options (like classes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants