Repository URL to install this package:
|
Version:
2.1.2 ▾
|
(function ($, Drupal) {
/**
* Add new command for reading a message.
*/
Drupal.AjaxCommands.prototype.populateDropdown = function (ajax, response, status) {
// Populate select
var dropdown = $(response.selector);
$(dropdown).find("option[value!='_none']").remove();
dropdown.prev(".input-select").children(".input-select-options").html("").removeAttr("style");;
dropdown.prev(".input-select").children(".input-select__label").html(dropdown.text());
dropdown.prev(".input-select").children(".input-select-options").append($("<div />").addClass("input-select__border"));
$.each(response.options, function (key, val) {
dropdown.append($("<option />").val(key).text(val));
dropdown.prev(".input-select").children(".input-select-options").append($("<li />").addClass("input-select-options__option").val(key).text(val));
});
dropdown.prev(".input-select").children(".input-select-options").append($("<li />").addClass("input-select-options__option input-select-options__option--none").data("value", "none").text(Drupal.t('None')));
}
})(jQuery, Drupal);