I have an variable array called data, for IGcombobox datasource, I want to change the array when I click my #select, how can I do that? With this code it doesn't change the variable. Also I could just use php, but I dont want to do that!
<div id="checkboxSelectCombo" name="kanal" style="position:absolute;" ></div>
<select id="seade" name="seade">
<?php for($i = 1; $i <= $devi; $i++) {
echo '<option value="' . $i . '">' .$device_name[$i]. '</option>';
} ?>
</select>
$(function () {
var data = [
{ ID: "1", Name: "Vooluandur 1" },
{ ID: "2", Name: "Meeter 1" }
];
$("#seade").on('click', function(event) {
console.log($("#seade").val());
if ($("#seade").val() == 2) {
var data = [
{ ID: "3", Name: "Vooluandur 2" },
{ ID: "4", Name: "Meeter 2" }
];
}
});
$("#checkboxSelectCombo").igCombo({
width: "100px",
dataSource: data,
textKey: "Name",
valueKey: "ID",
multiSelection: {
enabled: true,
showCheckboxes: true
}
});
});
datain the outer scope, remove thevarfrom within the#seadeclick handler, although note that this won't affect the data source you gave toigCombo. Presumably you need to destroy/reinitialise that library, or use a 'refresh' method - assuming it provides one