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 special handling of checkboxes by datalink. #87

Open
ylg opened this issue Jan 19, 2012 · 1 comment
Open

Add special handling of checkboxes by datalink. #87

ylg opened this issue Jan 19, 2012 · 1 comment
Labels

Comments

@ylg
Copy link

ylg commented Jan 19, 2012

There are a few pull requests handling checkboxes in ways specific to the author's needs: #24, #27, #56. I started working on a branch (here: https://github.com/ylg/backbone-rails/compare/master...checkbox_handling) building on their ideas to more generically handle checkboxes and wanted to get some thoughts before submitting a patch.

So far, what I've done is (given type === "checkbox"):

if the model's attribute holds a real Javascript array
  add or remove all occurrences of the checkbox's value attribute to or from the array

else if the checkbox's value is boolean-like, e.g., true, yes, on, or 1
  set the model's attribute to a boolean based on the checked status (or inverse in the case of a false value)

else
  copy or clear the checkbox's value to the model's attribute

Some open questions:

  1. Is this even something the gem should address OTS?
  2. Is removing all the matched values from the array really the least surprising? (Am leaning towards just popping one occurrence)
  3. Should we also handle Backbone collections here? (Seems like it.)
  4. What's the thinking about writing tests for the datalink code?
@paramveer
Copy link

I will be awaiting the fix for this issue. We are trying to add multiple checkboxes to a page to support HABTM relationships between two models and we are facing a number of problems with the same.

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

No branches or pull requests

2 participants