[#258,model][xs]: tiny bugfix for cases where fields in raw state contain a non-string - fixes #258.

This commit is contained in:
Rufus Pollock
2012-10-19 07:57:47 +01:00
parent dd8641ded2
commit f6a3395b40
2 changed files with 18 additions and 1 deletions

View File

@@ -105,11 +105,12 @@ my.Dataset = Backbone.Model.extend({
}
// fields is an array of strings (i.e. list of field headings/ids)
if (fields && fields.length > 0 && typeof fields[0] === 'string') {
if (fields && fields.length > 0 && typeof(fields[0]) != 'object') {
// Rename duplicate fieldIds as each field name needs to be
// unique.
var seen = {};
fields = _.map(fields, function(field, index) {
field = field.toString();
// cannot use trim as not supported by IE7
var fieldId = field.replace(/^\s+|\s+$/g, '');
if (fieldId === '') {