Open disruptek opened 7 years ago
Also, it seems that inputs (even radio inputs) aren't properly deselected when the model changes -- this is some kinda 1.5-way binding. And when I deselect all checkbox elements, they are completely removed from the view. Go figure.
The
checked
binding handler is not working for me against array attributes. Obviously, this code has been in production for ages, so perhaps I'm simply missing something, but I really cannot see how this could possibly be working correctly for others.Let's walk through the
set()
for thechecked
binding handler. This function is called with a jQuery selection of the bound input elements and the incoming attribute value from the model.This is an immediate problem, because
value
is an array of values here, so we've effectively emptied$element
with this statement.Now this check to see if the
$element
is a radio input will throw an exception because we're attempting totoLowerCase()
an undefined value.isRadio()
is reproduced below.Next we check to see if
value
is an array and then look for$element
's value therein. This doesn't work, of course, because$element
is empty. Even if it remained a list of jQuery elements, this operation wouldn’t work correctly because jQuery will only return the first selected element’sval()
and underscore'scontains()
is expecting to operate upon a single value.That
$element
is still empty, so thechecked
property cannot be set correctly in any event!Here is
isRadio()
for completeness: