Closed technikhil314 closed 9 years ago
I have already discussed it with Kevin Partington which you can find it in the discussion of the issue.
I think a rough sketch for a unit test would look something like this:
test("Radio button 'checked' attribute should not override 'checked' property in view-to-model binding", function () {
var View = Backbone.View.extend({
render: function () {
this.$el.empty();
this.$el.append('<input type="radio" name="test" checked="checked" value="incorrect">');
this.$el.append('<input type="radio" name="test" value="correct">');
return this;
}
});
var model = new Backbone.Model();
var modelBinder = new Backbone.ModelBinder();
var view = new View().render();
view.$("[value=correct]").click();
modelBinder.bind(model, view.$el, { myValue: "[name=test]" }, { initialCopyDirection: Backbone.ModelBinder.Constants.ViewToModel });
strictEqual(model.get("myValue"), "correct");
});
Hope that helps.
sure kevin will do it
Changed the attr function to prop on line 303