【问题标题】:Modify placeholder - Jquery Sumoselect - Dropdown修改占位符 - Jquery Sumoselect - 下拉
【发布时间】:2015-08-03 16:33:10
【问题描述】:

我在我的应用程序中使用插件 Jquery SumoSelect Multi Select,我想知道如何切换占位符以重新加载选择实例。

我通过 AJAX 在“选择”实例中加载新选项,但占位符保持与开始时设置的相同。

HTML 选择

<Select id = "c_ba" multiple = "multiple" disabled> </select>

实例

 $("#C_ba").SumoSelect ({
placeholder "Neighborhoods", //initial placeholder
okCancelInMulti: true,
selectAll: true
});

在另一个选择中,我为上面的选择充电:

$('#C_ci').Change(function (e) {
SelectValue var = $(this).val();

$ .ajax ({
type: 'GET'
url: 'rotinas.asp'
date: "action = carrega_bairros & cod_cidade = '+ SelectValue,
success: function (html) {

var str = html;
var arr = str.split ("###");
arraux var = new Array ();

var select = $("#c_ba"); //html select initial
var options = '';

select.css ({'display', 'none'});
select.empty ();

if (str! = '') {
for (var x = 0; x <arr.Length; x ++) {
arraux = arr [x] .Split ("...");
options + = "<option value = '" + arraux [0] + "'>" + arraux [1] + "</ option>";
}

select.append (options);
select [0] .sumo.enable (); // Enable the SUMO SELECT 
select [0] .sumo.reload (); // Reload With news options loads

// Here I would like to exchange the original placeholder "Neighborhoods" to the following placeholder (eg.): "Select the Neighborhoods"

} Else {
select [0] .sumo.disable ();
select [0] .sumo.reload ();
}
},

error: function (e) {
// Called When there is an error
console.log (e.Message);
}
});

【问题讨论】:

    标签: javascript jquery sumoselect.js


    【解决方案1】:

    根据 Sumoselect 的文档,选择标签中的原生占位符属性具有最高优先级。因此,您可以在重新加载 sumoselect 之前更改 select 标记的占位符属性(使用 jQuery attr() 方法)。

    select.append(options);
    select.attr("placeholder","Select the Neighborhoods");
    select[0].sumo.enable();
    select[0].sumo.reload();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-09
      • 2018-12-18
      • 1970-01-01
      • 2014-09-24
      • 2013-10-09
      • 2016-01-22
      • 2020-12-17
      • 2014-05-14
      相关资源
      最近更新 更多