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

Syphon.deserialize issue with checkboxes #27

Closed
diasjorge opened this issue Jul 16, 2013 · 2 comments
Closed

Syphon.deserialize issue with checkboxes #27

diasjorge opened this issue Jul 16, 2013 · 2 comments

Comments

@diasjorge
Copy link

If you want to deserialize a model into multiple checkboxes it doesn't behave correctly.

For instance if you have a model like:

{languages: ['en']}

and a form:

<input name="languages[]" type="checkbox" value="en">
<input name="languages[]" type="checkbox" value="fr">

Then syphon will check both checkboxes.

Our current solution is to only check the checkboxes that actually match on the value like:

Backbone.Syphon.InputWriters.register("checkbox", function ($el, value) {
    if (_.isArray(value)) {
        if (_.contains(value, $el.val())) {
            $el.prop("checked", true)
        }
    } else {
       $el.prop("checked", value)
    }
})
@jamiebuilds
Copy link
Member

@diasjorge Sorry this wasn't addressed sooner. It has now been marked critical.

@rhubarbselleven
Copy link
Contributor

Hi @diasjorge I'm going to close this one as a duplicate of #25

Thanks for your hint around the InputWriter

Ping @rogelio2k

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

No branches or pull requests

3 participants