Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 同一jQuery插件的多个实例_Asp.net_Jquery Ui_Jquery Plugins - Fatal编程技术网

Asp.net 同一jQuery插件的多个实例

Asp.net 同一jQuery插件的多个实例,asp.net,jquery-ui,jquery-plugins,Asp.net,Jquery Ui,Jquery Plugins,在一个aspx页面中,我调用了两个列表框的jquery插件,如下所示 $(document).ready(function() { $("select.select_AdditionalLanguages").custSelectBox(); $("select.select_Organisations").custSelectBox(); }); 问题是,在插件jQuerythis中保存了最后加载的列表框。请建议如何解决这个问题。我也尝试过下面的方法,但没有

在一个aspx页面中,我调用了两个列表框的jquery插件,如下所示

$(document).ready(function() { 
     $("select.select_AdditionalLanguages").custSelectBox();      
     $("select.select_Organisations").custSelectBox();
});
问题是,在插件jQuerythis中保存了最后加载的列表框。请建议如何解决这个问题。我也尝试过下面的方法,但没有成功

 $(document).ready(function() {

        var languages = $('<%=AdditionalLanguages.ClientID%>');
        if (languages) {
            languages.custSelectBox();
        }
        alert(languages);
        var organizations = $('<%=Organisations.ClientID%>');
        if (organizations) {
            organizations.custSelectBox();
        }
    });
编辑:


通过为两个列表框使用相同的类名,然后将两个列表框对象传递给插件,解决了这个问题 $'select.select_field'.custSelectBoxnull,$'EditUsers_Organizations',$'EditUsers_AdditionalLanguages';
这可能不是最好的解决方案,但其他任何解决方案都不适合我。

两个列表框将有两个不同的ID

$.'listbox1'.custSelectBox


$.'listbox2'.custSelectBox

通过为两个列表框使用相同的类名,然后将两个列表框对象传递给插件$'select.select_field'。custSelectBoxnull,$'EditUsers_organizations',$'EditUsers_AdditionalLanguages';这可能不是最好的解决方案,但其他方法对我来说都不管用。

我已经尝试了ID和类。插件正在加载,但我只得到一个实例。