vicb/bsmSelect — pull request #16 by S0RIEN (2011-11-16 13:16:18+00:00)
Title: added 2 events to be able to modify data 

usecase:
i need to have items with desired order and options sorted alphabeticaly

plugin:

onPreBuildSelect: function(bsm, original) {
//sort data with desired order
var selected = original.find('option:selected');
var notselected = original.find('option:not(:selected)');

selected.sort(function(a,b) {

if ($(a).attr('index') > $(b).attr('index')) return 1;
else if ($(a).attr('index') < $(b).attr('index')) return -1;
else return 0
});

original.empty().append(notselected).append(selected);
},

onPostBuildSelect: function(bsm, bsmselect) {
//perform alphabetical sort for options
this.sortNodes(bsmselect[0].options);
},