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'));
todo2.set({"completed": false});
console.log('completed: ' + todo2.get('completed'));
var Person = Backbone.Model.extend();
var person = new Person();
person.set({
name: "<b>John Doe</b><br>",
contact_num:'0987654321'
});
document.write( person.get('name'));
document.write( person.escape('name'));
if(person.has('contact_num')) {
document.write("The person is having contact number");
} else {
document.write("The person is not having contact number");
}
var employee=person.clone();
document.write("\n Name of the Employee: ", employee.get('name'));
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.