Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
54
rated 0 times [  60] [ 6]  / answers: 1 / hits: 16797  / 11 Years ago, sat, june 8, 2013, 12:00:00

I'm trying to use backbone.js model.set property. The second alert function should fire off after todo1.set is being implemented. However it is not.

Here is the jsfiddle link: http://jsfiddle.net/SGEkn/



var Todo = Backbone.Model.extend({
defaults: {
title: Harsh,
completed: false
},
initialize: function() {
console.log('This model has been initialized.')
}
});

var todo2 = new Todo({
title: 'Set through instantiation.',
completed: true
});
console.log('Todo title: ' + todo2.get('title'));
console.log('Todo completed ' + todo2.get('completed'));

alert(ok);

todo2.set(title, 'Title set');

alert(ok);

console.log(todo2.get('title'));
todo.set(completed, false);

console.log('completed: ' + todo2.get('completed'));

More From » jquery

 Answers
60

You should be passing an object and not the arguments individually.



todo2.set({title:'Title set'});

[#77735] Friday, June 7, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dayshadelaniej

Total Points: 668
Total Questions: 121
Total Answers: 121

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;