Skip to content

Instantly share code, notes, and snippets.

@rissajeanne
Created February 6, 2012 21:34
Show Gist options
  • Save rissajeanne/1755036 to your computer and use it in GitHub Desktop.
Save rissajeanne/1755036 to your computer and use it in GitHub Desktop.
updateVersionDropdown : function() {
var versionsByLang = {};
// Loop through the version model
_.each(
// Group versions by language,
// and sort the lang keys alphabetically.
_.groupBy(_.sortBy(this._versions.models, function (ver) {
return ver.get('lang');
}), function (ver) {
return ver.get('lang');
}),
// Sort the versions within each lang group
// and populate the new object
function(version, lang) {
versionsByLang[lang] = _.sortBy(version, function(ver) {
return ver.get('display_abbreviation');
});
}
);
var selectorHTML = ABS.jst.PassageVersionSelector({
versionsByLang: versionsByLang,
current: this.collection.primaryModel.get('version')
});
this.$('div.change-version').empty().append(selectorHTML);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment