Every time I invoke Client2.config.select2() everything is getting redefined.
Is there a way to prevent the re-definition of such an function/object? I.e. if I wanted to have another variable which saves some elements within this object, running Client2.config.select2()
would override it.
Is there a well-known pattern to do this?
Client2.config.select2 = function() {
var coreIDs = ['clientID', 'cptyID' , 'sym'];
var nonCoreIDs = ['groupBy','groupBy_impact_1','groupBy_impact_2',
'groupBy_impact_3','groupBy_impact_4'];
//non dynamic filters
var autoCompleteSettings = function () {
return {
allowClear : true,
minimumInputLength : 2,
multiple : true,
placeholder: "Select ",
closeOnSelect : false,
openOnEnter : true,
ajax: {
url : "../my?page=search",
dataType : 'json',
data : function(term, page) {
return {
q : term
};
},
results : function(data, page) {
return {
results : data
};
}
}
};
};
var multipleSettings = function () {
return {
placeholder : "Select ",
allowClear : true,
closeOnSelect : false,
maximumSelectionSize: 6
};
};
return {
getAutoCompleteSelectSettings: function() {
return new autoCompleteSettings();
},
getMultipleSelectSettings: function() {
return new multipleSettings();
},
getCoreSelect2IDs: function () {
return coreIDs;
},
getNonCoreSelect2IDs: function () {
return nonCoreIDs;
},
getSelect2IDs : function() {
return coreIDs.concat(nonCoreIDs);
}
}
};