codebrew / backbone-rails

Easily use backbone.js with rails 3.1
MIT License
1.62k stars 255 forks source link

Boolean attributes now sync properly for radio buttons and checkboxes. #148

Open escoberik opened 11 years ago

escoberik commented 11 years ago

Checkable inputs need the property "checked" to be settled to true/false instead of the "value" attribute.

gabetax commented 11 years ago

Array#indexOf is not supported in IE8 and earlier. Given that backbone relies on underscore.js, you could instead rely on _.contains() (note the nativeIndexOf check):

  $.fn.isCheckable = function() {
    return _.contains(["checkbox", "radio"], this.attr("type"));
  };

Otherwise, :thumbsup: