This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse: function (response) { | |
console.log('Collection - parse'); | |
this.reset(response); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = {}; | |
App.BBCollection = Backbone.Collection.extend({ | |
initialize: function (options) { | |
console.log('Collection - initialize'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function() { | |
var events = {}; | |
var publishedEvents = {}; | |
var subscribe = function (subscriber, eventName) { | |
//if new event then create an entry in the events map | |
if(!events.hasOwnProperty(eventName)) { | |
events[eventName] = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var TestView = Backbone.View.extend({ | |
el: '#container', | |
initialize: function () { | |
console.log('Inside Init'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AppRouter = Backbone.Router.extend({ | |
routes: { | |
"": "index", | |
"welcome": "welcome" | |
}, | |
index: function() { | |
loginViewInstance.render(); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CarCollection = Backbone.Collection.extend({ | |
//Specify REST URL | |
url: 'http://localhost:8500/rest/Car/CarService', | |
initialize: function () { | |
this.bind("reset", function (model, options) { | |
console.log("Inside event"); | |
console.log(model); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>localStorage Test</title> | |
<script type="text/javascript" > | |
var count = 0; | |
var storageHandler = function () { | |
alert('storage event 1'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a Car Model | |
var Car = Backbone.Model.extend({ | |
//Validate the Car Model | |
validate: function(attr) { | |
if( !(attr.brand && attr.model && attr.color) ) { | |
return "Error Occurred"; | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create a Car Model | |
var Car = Backbone.Model.extend({ | |
//Validate the Car Model | |
validate: function(attr) { | |
if( !(attr.brand && attr.model && attr.color) ) { | |
return "Error Occurred"; | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define an Observer class | |
function Observer(name, updateFn) { | |
this.name = name; | |
this.updateFn = updateFn; | |
} | |
//Create an instance of Observer class | |
observerObj = new Observer("observer1", function(msg) { console.log(msg); }); | |
//Create an instance of the Subject and provide the observer object |