gmac / backbone.epoxy

Declarative data binding and computed models for Backbone
http://epoxyjs.org
MIT License
615 stars 89 forks source link

Radio buttons not firing on change #77

Closed impatient closed 9 years ago

impatient commented 10 years ago

Radio button name=gender with two radios (MALE/FEMALE) not updating model.

Using current prod release

http://jsfiddle.net/P8r4v/5/

gmac commented 9 years ago

Definitely needs investigation. Internalizing this sample code:

<form id="me">
    <input name="gender" type="radio" value="MALE">M </input>
    <input name="gender" type="radio" value="FEMALE">F </input>
    <input name="relief" type="text" value=""/>
</form>
var m = new Backbone.Model({gender:'MALE', relief:'ee'});

var BindingView = Backbone.Epoxy.View.extend({
    el: '#me',
    bindings : {
        'input[name="gender"]': 'checked:gender',
        'input[name="relief"]': 'value:relief'
    },
    initialize: function(){
        this.listenTo(this.model, 'change', function() { 
          console.log(this.model.toJSON());
          console.log(this.$(':checked').val());
        });
    }
});

var b = new BindingView({model:m});
gmac commented 9 years ago

Should be set. Thanks @bragradon.