-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
For example, a periodic poller might do an AJAX call for updates, then tell Flapjack to change the tree.
Option 1: use calls directly on the Flapjack instance
var aFlapjack = ...;
function doPoll() {
$.ajax({
...
success: function(data) {
var group = aFlapjack.findOrCreateGroup(...);
group.push(...);
}
});
}
Option 2: use events on the <select> and pass data:
function doPoll() {
$.ajax({
...
success: function(data) {
$('#some_select').trigger('data-change.flapjack'), data);
}
});
}
Option 3: add DOM elements to the <select>:
function doPoll() {
$.ajax({
...
success: function(data) {
var newOption = $("<option value='" + data.value + "'>" + data.text + "</option>");
$('#some_select')
.append(newOption)
.trigger('data-added.flapjack', newOption);
}
});
}
Option 3 has the disadvantage that it's not necessarily compatible with a customer <select> parser -- although I suppose if the programmer is customizing the parser, she could compensate in the rendering of the new <option> or <optgroup>.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels