簡體   English   中英

jQuery UI MultiSelect Widget-Cant可以應用於一項

[英]jQuery UI MultiSelect Widget-Cant able to apply in one item

我正在使用這個jQuery UI Multiselect Widget腳本:asp.net中的http://runnable.com/Ug​​MdJqspu4chAAAP/how-to-create-jquery-ui-multiselect-widget 。我有一個包含母版頁的子頁。默認情況下,我正在將此控件應用於所有dropdownlist 。我想申請一個Dropdownlist 有人可以幫我嗎?

<script type="text/javascript">
    $(function () {
        /*
        define global variable,
        and store message container element.
        */
        var warning = $(".message");

        $('select').multiselect(
        {
            /*
            The name of the effect to use when the menu opens.
            To control the speed as well, pass in an array
            */
            show: ["slide", 1000],
            /*
            The name of the effect to use when the menu closes.
            To control the speed as well, pass in an array
            */
            hide: ["slide", 1000],
            /*
            Either a boolean value denoting whether or not to display the header,
            or a string value.
            If you pass a string,
            the default "check all", "uncheck all", and "close"
            links will be replaced with the specified text.
            */
            header: "Choose only TEN items!",
            /*
            Fires when a checkbox is checked or unchecked,
            we are using this option to restrict,
            user to select no more than 3 option
            */
            click: function (e) {
                if ($(this).multiselect("widget").find("input:checked").length > 10) {
                    warning.addClass("error").removeClass("success").html("You can only check three checkboxes!");
                    return false;
                }
                else {
                    warning.addClass("success").removeClass("error").html("Check a few boxes.");
                }
            }
            /*
            .multiselectfilter()
            Initialize filtering on any of your multiselects
            by calling multiselectfilter() on the widget.
            */
        }).multiselectfilter();
    });
</script>

$('select').multiselect()當我傳遞dropdown-list Id此控件不起作用。僅在提供'select'同時起作用,並且同時將其應用於所有dropdown-list 但我想申請一個dropdown-list 。有人可以建議我嗎?

使用ID應該可以工作

$(document).ready(function(){
   $("#example").multiselect();
});

下面的參考鏈接使用的是相同的插件,您可以檢查瀏覽器控制台是否存在任何JavaScript錯誤?

http://www.erichynds.com/blog/jquery-ui-multiselect-widget

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM