Skip to content

Instantly share code, notes, and snippets.

@jboonstra
Forked from rissajeanne/gist:1755036
Created February 6, 2012 21:59
Show Gist options
  • Save jboonstra/1755212 to your computer and use it in GitHub Desktop.
Save jboonstra/1755212 to your computer and use it in GitHub Desktop.
updateVersionDropdown : function() {
var versionsByLang = {},
getLang = function (v) { return v.get('lang'); },
selectorHTML;
// Loop through the version model
_.each(
// Group versions by language,
// and sort the lang keys alphabetically.
_.groupBy(_.sortBy(this._versions.models, getLang), getLang),
// Sort the versions within each lang group
// and populate the new version object
function(version, lang) {
versionsByLang[lang] = _.sortBy(version, function(ver) {
return ver.get('display_abbreviation');
});
});
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