diff --git a/backbone.modelbinding.js b/backbone.modelbinding.js index b5f4f56..9e867a9 100644 --- a/backbone.modelbinding.js +++ b/backbone.modelbinding.js @@ -79,7 +79,7 @@ Backbone.ModelBinding.Configuration = (function(){ configureAllBindingAttributes: function(attribute){ this.storeBindingAttrConfig(); bindingAttrConfig.text = attribute; - bindingAttrConfig.texarea = attribute; + bindingAttrConfig.textarea = attribute; bindingAttrConfig.password = attribute; bindingAttrConfig.radio = attribute; bindingAttrConfig.checkbox = attribute; diff --git a/spec/javascripts/configureAllBindingAttributes.spec.js b/spec/javascripts/configureAllBindingAttributes.spec.js index 6dfd395..8a828fe 100644 --- a/spec/javascripts/configureAllBindingAttributes.spec.js +++ b/spec/javascripts/configureAllBindingAttributes.spec.js @@ -2,6 +2,7 @@ describe("configure all binding attributes", function(){ beforeEach(function(){ this.model = new AModel({ name: "some dude", + bio: "not much", education: "graduate", graduated: "maybe", drivers_license: true @@ -36,6 +37,27 @@ describe("configure all binding attributes", function(){ }); }); + describe("textarea element binding using configurable attribute", function(){ + it("bind view changes to the model's field, by configurable convention", function(){ + var el = this.view.$("#v_bio"); + el.val("biography"); + el.trigger('change'); + + expect(this.model.get('bio')).toEqual("biography"); + }); + + it("bind model field changes to the form input, by convention of id", function(){ + this.model.set({bio: "biography, schmiography"}); + var el = this.view.$("#v_bio"); + expect(el.val()).toEqual("biography, schmiography"); + }); + + it("binds the model's value to the form field on render", function(){ + var el = this.view.$("#v_bio"); + expect(el.val()).toEqual("not much"); + }); + }); + describe("radio element binding using configurable attribute", function(){ it("bind view changes to the model's field, by configurable convention", function(){ var el = this.view.$("#graduated_no");