Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Cannot use 'in' operator to search for 'id' in text #10

Open
jaysshortt opened this issue Nov 12, 2012 · 1 comment
Open

Cannot use 'in' operator to search for 'id' in text #10

jaysshortt opened this issue Nov 12, 2012 · 1 comment

Comments

@jaysshortt
Copy link

Hi,

I can't seem to work out why the following code is throwing an error:

it('Attributes can be set on the model instance when it is created.', function() {
    var todo = new Todo({ text: 'Get oil change for car.' });
    var expectedText = 'FIX ME';
    todo.set('text',"FIX ME");
    expect(expectedText).toEqual(todo.get('text'));
});

The console states: TypeError: Cannot use 'in' operator to search for 'id' in text -> koans/aboutModels.js:24

Any idea where I've gone wrong?

Thanks

@jaysshortt
Copy link
Author

Hmmm I've just tried changing

todo.set('text',"FIX ME");

to

todo.set({'text':"FIX ME"});

which works! But why doesn't the origina statement work? Backbone.js' website actually states that the following should work?

book.set("title", "A Scandal in Bohemia");

Any help would be gratefully received.
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant