powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 413 forks source link

Error with Checkboxes.getValue() #446

Closed NowellVanHoesen closed 8 years ago

NowellVanHoesen commented 9 years ago

Using jQurery 1.11.1, backbone-forms 0.14.0 When using form.commit() on a form with checkboxes that have at least one checked I am getting an error: chrome - Uncaught TypeError: undefined is not a function backbone-forms.js:1930 firefox - TypeError: $ is not a function (line 1930, col 18)

The error is $(this).val()

this.$('input[type=checkbox]:checked').each(function() {
      values.push($(this).val());
});

I changed the line to

      values.push( this.value );

and it worked in my tests.

glenpike commented 8 years ago

Possibility that it's trying to use $ as a global - maybe running jQuery in no-conflict mode or other?

Should be able to fix with "local" variable:

var self = this;
this.$('input[type=checkbox]:checked').each(function() {
      values.push(self.$(this).val());
});

Not sure if this needs a test?