-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when validating model with two equal array names #309
Comments
Can you please include your model definition including its
|
The error appears even though there is no validation-block defined. (when I call model.set(), which calls .validate() etc.) This is what my Activity-model looks like while debugging (js-code is minimal): it fails in "flatten(obj, into, prefix) backbone-validation.js:78
When flattening Task.CategoryIds, _.isArray(key) is true.. then there is a recursive call to: now on line 82 it fails, because obj is a string and not an array. obj = "con": Uncaught TypeError: Cannot use 'in' operator to search for '0' in con Activity.Task.CategoryIds is an array of strings. Is there something wrong with my model? |
My model looks like this:
Activity
When I call model.validate(), I get the following error:
Uncaught TypeError: Cannot use 'in' operator to search for '0' in vacation
Is this because I have two attributes named "CategoryIds" in my model? One attribute "activity.CategoryIds[]" and one nested attribute "activity.Task.CategoryIds[]". Maybe flattening isn't working? Is this a bug, and can it be fixed? :-) Or am I doing something wrong? (validation works on simpler models).
trace:
Uncaught TypeError: Cannot use 'in' operator to search for '0' in vacationb.each.b.forEach @ underscore-min.js:20Backbone.Validation.flatten @ backbone-validation.js:82(anonymous function) @ backbone-validation.js:86b.each.b.forEach @ underscore-min.js:20(anonymous function) @ backbone-validation.js:85b.each.b.forEach @ underscore-min.js:20Backbone.Validation.flatten @ backbone-validation.js:82(anonymous function) @ backbone-validation.js:90b.each.b.forEach @ underscore-min.js:20Backbone.Validation.flatten @ backbone-validation.js:82Backbone.Validation.options.validate @ backbone-validation.js:285Page.extend.save @ ActivityEditor2.js:95jQuery.event.dispatch @ jquery-1.9.1.js:3074jQuery.event.add.elemData.handle @ jquery-1.9.1.js:2750
The text was updated successfully, but these errors were encountered: