Created
March 20, 2012 15:04
-
-
Save imakewebthings/2136632 to your computer and use it in GitHub Desktop.
Overriding and modifying Stack View type properties
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($, window, undefined) { | |
/* Let's say we want to completely override the template and adapter | |
for the webpage type. Simple enough, just get the type and set each of | |
those proeprties to new values. */ | |
var webpage = window.StackView.get_types().webpage; | |
webpage.template = '<li><%= id %></li>'; | |
webpage.adapter = function(item, options) { | |
return { | |
id: item.id | |
} | |
}; | |
/* What if we still want to use the old values, but just make further | |
changes? In this contrived example, let's say we still want to do the | |
heat calculation but then turn it up by adding 2. */ | |
var soundrecording = window.StackView.get_types().soundrecording; | |
var old_adapter = soundrecording.adapter; | |
soundrecording.adapter = function(item, options) { | |
var result = old_adapter(item, options); | |
result.heat += 2; | |
return result; | |
}; | |
})(jQuery, window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment