diff --git a/spec/javascripts/serialize.spec.js b/spec/javascripts/serialize.spec.js index 3647385..48c47c9 100644 --- a/spec/javascripts/serialize.spec.js +++ b/spec/javascripts/serialize.spec.js @@ -306,6 +306,24 @@ describe('serializing a form', function() { }); }); + describe('when given a form element with nested inputs', function() { + beforeEach(function() { + this.form = $( + '
' + + '
' + + '' + + '
' + + '
' + )[0]; + + this.result = Backbone.Syphon.serialize(this.form); + }); + + it('retrieves the inputs\' values', function() { + expect(this.result.foo).to.equal('bar'); + }); + }); + describe('when given more than 1 form', function() { beforeEach(function() { this.View = Backbone.View.extend({ diff --git a/src/backbone.syphon.js b/src/backbone.syphon.js index f15d9e3..d5b6b95 100644 --- a/src/backbone.syphon.js +++ b/src/backbone.syphon.js @@ -147,7 +147,7 @@ var getElementType = function(el) { // Otherwise, get the form fields from the view. var getForm = function(viewOrForm) { if (_.isUndefined(viewOrForm.$el)) { - return $(viewOrForm).children(':input'); + return $(viewOrForm).find(':input'); } else { return viewOrForm.$(':input'); }