Skip to content

Instantly share code, notes, and snippets.

View icodesido's full-sized avatar

Ivan icodesido

View GitHub Profile
// backbone.js continues to impress, I needed to get data from a jsonp api
// I really wanted to do this the "right" backbone.js way and create a model and call fetch.
// But the default backbone synch is not jsonp
// Turns out you can override a synch on a per model basis (thanks stackoverflow)
// whats nice is backbone.js continue to work as expected with the override
// here's a snippet (some changes to protect our privacy). An improvement could be to create a jsonp model class which MyModel inherits
// the synch function is most important below, that's what tells backbone it's jsonp
MyModel = Backbone.Model.extend({
@icodesido
icodesido / Bind and call compared
Created November 28, 2013 17:41
native js vs underscore
function Developer(skill) {
this.skill = skill;
this.says = function(){
alert(this.skill + ' rocks!');
}
}
var john = new Developer('Backbone');
var func = john.says;
func.apply(john);
@icodesido
icodesido / Most popular in section
Created October 23, 2012 11:02
Most popular in Technology with the styles for the whole promo col
@icodesido
icodesido / Replace text
Created June 6, 2012 11:21
Change comment count text on the fly
if(jQuery('.discussion .toolbar:contains("Open for comments")').length){
commentCount = jQuery('.content-comment-count');
commentCount.text(commentCount.text().replace('Comments','Jump to comments'));
}
Variants:
1 Jump to comments
2 See all comments
3 Read the comments
4 Readers' comments