fetch toolbar results without page reload (#518)

This commit is contained in:
Kevin Papst
2019-01-23 02:45:33 +01:00
committed by GitHub
parent a9ece209ae
commit 89abaa9dda
21 changed files with 344 additions and 117 deletions

View File

@@ -97,11 +97,21 @@ $(function() {
method: 'GET',
dataType: 'json',
success: function(data){
$('#' + targetSelect).find('option').remove().end().find('optgroup').remove().end();
var selectName = '#' + targetSelect;
var $select = $(selectName);
var $emptyOption = $(selectName + ' option[value=""]');
$select.find('option').remove().end().find('optgroup').remove().end();
if ($emptyOption.length != 0) {
$select.append('<option value="">' + $emptyOption.text() + '</option>');
}
$.each(data, function(i, obj) {
$('#' + targetSelect).append('<option value="' + obj.id + '">' + obj.name + '</option>');
$select.append('<option value="' + obj.id + '">' + obj.name + '</option>');
});
$('#' + targetSelect).trigger('change')
$select.trigger('change');
}
});
});