A more recent modification of the library that I added subsequently resolved the issue.
In this._defaults
I added 3 lines (onBind, onInit, onDetach)
function Selectbox() {
this._state = [];
this._defaults = { // Global defaults for all the select box instances
classHolder: "sbHolder",
classHolderDisabled: "sbHolderDisabled",
classSelector: "sbSelector",
classOptions: "sbOptions",
classGroup: "sbGroup",
classSub: "sbSub",
classDisabled: "sbDisabled",
classToggleOpen: "sbToggleOpen",
classToggle: "sbToggle",
classFocus: "sbFocus",
speed: 200,
effect: "slide", // "slide" or "fade"
onChange: null, //Define a callback function when the selectbox is changed
onOpen: null, //Define a callback function when the selectbox is open
onClose: null, //Define a callback function when the selectbox is closed
onBind: null,
onInit: null,
onDetach: null
};
}
Added lines in +
+ self._initSelectBox(target);
sbSelector.appendTo(sbHolder);
sbOptions.appendTo(sbHolder);
sbHolder.insertAfter($target);
$("html").on('mousedown', function(e){
e.stopPropagation();
$("select").selectbox('close');
});
$([".", inst.settings.classHolder, ", ,", inst.settings.classSelector].join("")).mousedown(function(e){
e.stopPropagation;
});
+ self._bindSelectbox(target);
Within _detachSelectbox added the following
var onDetach = this._get(inst, 'onDetach');
if (onDetach != null)
{
onDetach.apply({inst.input ? inst.input[0]: null), [inst]);
}
Right above
$("#sbHolder_" + inst.uid).remove();
$.data(target, PROP_NAME, null);
$(target).show();
Then I Added the Init and Bind Methods
_initSelectbox: funciton (target){
var onInit, inst = this._getInst(target);
if (inst) {
onInit = this._get(inst, 'onInit');
if (onInit != null)
{
onInit.apply({inst.input ? inst.input[0]: null), [inst]);
}
}
}
_bindSelectbox: funciton (target){
var onBind, inst = this._getInst(target);
if (inst) {
onBind = this._get(inst, 'onBind');
if (onBind != null)
{
onBind.apply({inst.input ? inst.input[0]: null), [inst]);
}
}
}
Invoking Code (AngularJS)
function bindDrodown(selector)
{
angular.forEach($(".selector").function(elem){
//set span value to selected value of dropdown
id = $(elem).attr("id");
itemid = $("#"+id).data("itemid");
setDrowDownValue(elem);
setSpanValue(itemid);
});
$(selector).selectbox({
onInit: function (inst){
},
onBind: function (inst){
},
onChange: function (id, inst){
//change code here
},
onDetach: function(inst){
}
});
}