// Populate a select list with pt codes.
this.populateCodeList = function (ptName_, listSelector_) {
if (!ptName_) { return self.displayError("Invalid pt name", "populatecodeList"); }
if (!listSelector_) { return self.displayError("Invalid list selector", "populatecodeList"); }
var pt = self.registry.pt[ptName_];
if (!pt) { return self.displayError("Invalid PT: " + ptName_, "populateCodeList"); }
var html = "";
$_.each(pt.codes, function (index_, code) {
if (!code || !code.id || !code.name) { return self.displayError("Invalid code at index " + index_, "populateCodeList"); }
html += "<option value='" + code.id + "'>" + code.name + "</option>";
});
$_(listSelector_).html(html);
};
I am calling the above function like the following in my code:
app_.populateCodeList("First Attribute", self.selectors.add_attribute_dialog + " .attribute-name");
Everything works fine. However, when I try to call the above function like this with second attribute separated
by comma as follows :
app_.populateCodeList("First Attribute,Second Attribute", self.selectors.add_attribute_dialog + " .attribute-name");
I get the following error Invalid PT:First Attribute,Second Attribute in populateCodeList
which is the result of this line in the above code if (!pt) { return self.displayError("Invalid PT: " + ptName_, "populateCodeList"); }
So basically my code is not programmed to handle two parameters separated by comma but single variable which is shown in the line
var pt = self.registry.pt[ptName_];
How can I make sure the above line accepts single as well as double parameters whenever needed?
Thanks