initComplete
initComplete
mehti
Posts: 35Questions: 13Answers: 0
Could someone help out. I have two pieces of code one works the other one doesn't.
Works:
$('#results').DataTable({
"initComplete": function(settings, json) {
$.each(json.data, function(index, value) {
$("#company").append('<option value="' + value.bank + '" selected="selected">' + value.bank + '</option>');
$("#frequency").append('<option value="' + value.provider + '" selected="selected">' + value.provider + '</option>');
});
$("#frequency").multipleSelect({
filter: true,
onUncheckAll: function() {
table.column(4).search("none", true).draw();
},
onCheckAll: function() {
table.column(4).search('').draw();
},
onClick: function() {
var value = "(";
$("ul li.selected").each(function(index, val) {
value += "(" + $(val).find('input').val() + ")|";
});
if (value == "(") {
value = "";
} else {
value = value.slice(0, -1);
value += ")";
}
table.column(4).search(value, true).draw();
}
});
$("#company").multipleSelect({
filter: true,
onUncheckAll: function() {
table.column(0).search("none", true).draw();
},
onCheckAll: function() {
table.column(0).search('').draw();
},
onClick: function() {
var value = "(";
$("ul li.selected").each(function(index, val) {
value += "(" + $(val).find('input').val() + ")|";
});
if (value == "(") {
value = "";
} else {
value = value.slice(0, -1);
value += ")";
}
table.column(0).search(value, true).draw();
}
});
}
However if I move the code into a function, it doesn't like this
$('#results').DataTable({
"initComplete": function(settings, json) {
setupFilter(json);
}
The web page:
[retracted]
select Russia, RUB and amount 121 to get some results.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
If you look in the console in your browser you will see a Javascript error:
You probably need to pass that variable through to the function or access the API some other way.
Allan
Thanks Allan, i'll investigate.