Sur*_*tel 5 ajax jquery jquery-select2
我正在使用带有 ajax 选项的 select2,当 ajax 运行时,会出现一个文本“搜索”,直到 ajax 成功。我想更改此文本(see in attached image)。
我的代码是:(来自https://select2.org 的参考)
$("#employee_id").select2({
ajax: {
url: "get_store_data.php?type=employee_data",
dataType: 'json',
delay: 250,
data: function (params) {
return {
phrase: params.term, // search term,
store_name: jQuery("#store_name").val(),
page: 1
};
},
processResults: function (data, params) {
// console.log(data);
params.page = params.page || 1;
return {
results: data.map(function(item) {
return {
id: item.name,
text: item.name
};
}),
pagination: {
more: 0
}
};
},
placeholder: 'Search for a member id',
cache: true
},
escapeMarkup: function (markup) { return markup; },
minimumInputLength: 1
});
Run Code Online (Sandbox Code Playgroud)
roh*_*anc 11
如果您理解正确,您希望更改在等待时出现的文本(等待 Ajax 完成。该文本在完成后消失。默认情况下,文本为“正在搜索...”。下面的代码会将其更改为“还有什么……”
$("#employee_id").select2({
language: {
searching: function() {
return "Something else...";
}
},
ajax: {
url: "get_store_data.php?type=employee_data",
// etc.
}
}
Run Code Online (Sandbox Code Playgroud)
请参阅有关Translation objects的 Select2 v4 文档。
| 归档时间: |
|
| 查看次数: |
5913 次 |
| 最近记录: |