站内搜索:
首页 >> 前端 >> 内容
BootstrapmultiSelect在页面POSTBack后不显示

时间:2017/3/9 9:13:00

BootstrapmultiSelect在页面POSTBack后不显示。

使用Bootstrap multip select

1.必须引用一个CSS文件,JQuery JS和两个bootstrap JS文件

2.当一个DropDownListChanged Index并且PagePostBack,pHideChoice显示(但是multiSelect不显示)

3.解决办法,把DropDownList的ChangeEvent注册到pageLoad事件中而非document.ready事件中

function initMultiSelect() {

var hideChoices = $("#<%=hfHideChoices.ClientID %>").val();

var listChoices = [];

if (hideChoices != null && hideChoices != "") {

listChoices = hideChoices.split(",");

}

$("#<%=ddlHideChoices.ClientID %>").val(listChoices);

}

function pageLoad() {

initMultiSelect();

$("#<%=ddlHideChoices.ClientID %>").change(function () {

var choices = $(this).val();

var hideChoices = $("#<%=hfHideChoices.ClientID %>").val();

if (hideChoices != null && hideChoices != "") {

var selectedCount = hideChoices.split(",").length;

var totalCount = $(this).children('option').length;

if (selectedCount + 1 == totalCount) {

alert("Notes: You cann't select all items.");

}

}

if (choices == null) {

$("#<%=hfHideChoices.ClientID %>").val("");

} else {

$("#<%=hfHideChoices.ClientID %>").val(choices.join());

}

});

$("#<%=ddl_Type.ClientID%>").change(function () {

$("#pHideChoice").hide();

if ($(this).val() == "7") {

$('.selectpicker').selectpicker('show');

$("#pHideChoice").show();

} else {

$('.selectpicker').selectpicker('hide');

}

});

if ($("#<%=ddl_Type.ClientID%>").val()=="7")

{

$('.selectpicker').selectpicker('show');

$("#pHideChoice").show();

}

}

  • 上一篇:Repond.js
  • 下一篇:浮动float:使用伪类实现,简单易操作
  • 返回顶部