This file contains hidden or 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 $tweetDiv = $("#tweets>div"); | |
$('li').on('click',function(){ | |
cleanDiv(); | |
getTweets($(this).find('a').data('link')); | |
$tweetDiv.fadeIn('slow'); |
This file contains hidden or 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 func1(num){ | |
var dfd = $.Deferred(); | |
if(typeof num= !== 'number'){ | |
dfd.reject('not a number'); | |
} | |
else{ | |
dfd.resolve(num); | |
} |
This file contains hidden or 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 func1(num){ | |
return $.Deferred(function(dfd){ | |
if(typeof num !== 'number'){ | |
dfd.reject('not a number'); | |
} | |
else{ | |
dfd.resolve(num); | |
} | |
}).promise() | |
} |
This file contains hidden or 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
$.when( | |
func1(), | |
func2(), | |
func3() | |
).then(...) |
This file contains hidden or 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
$("a").on('click',eventHanlers.clickHandler); |
This file contains hidden or 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 eventHandlers = { | |
name : 'Home Simpson', | |
clickHandler : function(){ | |
console.log('hello: ' + this.name); | |
} | |
}; | |
$("a").on('click',eventHanlers.clickHandler); |
This file contains hidden or 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 getMessages(name){ | |
return $.Deferred(function(dfd){ | |
var messages = []; | |
// static messages | |
messages.push("Hello " + name); | |
messages.push("Thank you for stopping by."); | |
This file contains hidden or 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
initialize : function(){ | |
app.contacts.on("load",$.proxy(this.addContacts(),this)); | |
} |
This file contains hidden or 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
app.NewView = Backbone.View.extend({ | |
initialize : function(){ | |
this.addContacts(); | |
}, | |
addContacts : function(){ | |
_.each(app.contacts.models, function(val, key){ | |
//add them to a drop down | |
}); |
This file contains hidden or 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
app.ContactCollection = Backbone.Collection.extend({ | |
model : app.Contact, | |
initialize : function(){ | |
this.fetch(); | |
}, | |
url : 'contacts/' | |
}); |