-
Notifications
You must be signed in to change notification settings - Fork 158
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
When using elAttribute, the value is not saved to the model for checkboxes #138
Comments
The "checked" attribute is only used to set the initial state of a checkbox. According the W3C spec, this is not a dynamic value that can be changed on a whim. See the jQuery discussion for a bit more depth on why this is a complex issue. Does this not work if you just remove the elAttribute? It should default appropriately. Btw, the "checked" behavior was recently updated by my changes to fix the use of attr and prop. |
Ahhhhh, I see. Yes I am on pretty up to date master branch. I agree that apparently checked is the wrong attribute to use, and instead should be used as a property. A couple of thoughts:
|
I haven't personally had a use for elAttribute in a two-way sense. It doesn't really make sense that we're talking two-way unless it's binding to a value or checked property anyway. Is a user inputting data to the style tag or title attribute that we then want propagated to the server? I don't really see this as valuable. Plus, any variation of this edge case could be easily achieved with a converter. I guess for my part it makes perfect sense that unless you bind to something that is editable and fires change events (an input) then there's not going to be a return value. As for the naming of I had a quick look for related and open issues and didn't find anything similar to this except for #75, which is about binding to a list of checkboxes. A quick scan of the closed issues reveals only the ones I submitted related to my change, and one about radios not firing a change event. Did I miss some that seem to be caused by "checked" used as elAttribute? |
Ah, my bad. I saw two other issues referenced by that pull request but actually they were opened by you.
I think you've explained pretty well how elAttribute works now, and why it works the way it does. Two thoughts:
Thinking about it more, I can't see a breaking change to remove or rename elAttribute as worth it, so I guess.. TLDR; add documentation, don't change anything is the best that can be done I think. |
I be happy to write up some new documentation in a PR... |
I suppose you should wait for @theironcook (Mr. Bart Wood) to chime in with his thoughts about the docs and usage. He is, after all the expert. As for my part, I've probably done a poor job explaining some of the behaviors. I don't think elAttribute implies anything about whether it's a two way binding and haven't meant to imply that. There just don't seem like there are logically many two-way things that can be bound to. I wonder if it would make sense to add Alas, I like to overthink things; I'm at least one half engineer : ) |
katowulf has done a very good job at explaining what's going on. @katowulf - would you like to be added as a contributor to the project? |
@theironcook shoot me a message at katowulf of the gmail realm regarding contributing. |
I'm (quite) surprised this wasn't caught by something.. am I doing something wrong here?
Example binding:
So, when this is changed, we hit
And this is going to return false, so we don't attempt to _copyViewToModel():
I propose changing _isBindingUserEditable to something like this:
The text was updated successfully, but these errors were encountered: