选择二JQuery的问题与ASP.NET的UpdatePanel [英] Select2 JQuery issue with ASP.NET UpdatePanel

查看:321
本文介绍了选择二JQuery的问题与ASP.NET的UpdatePanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个现有的解决方案,我一直问有选择二jQuery库,以加强。

Have a existing solution I have been asked to enhance with Select2 JQuery library.

有一个保存按钮一个UpdatePanel。在那个UpdatePanel的是一个ASP.NET的DropDownList。

Have an updatepanel with a save button. On that updatepanel is a ASP.NET DropDownList.

在文件准备好我发出

$('dropdownspecificclass。')选择2();

$('.dropdownspecificclass').select2();

在第一页使得它看起来像预期的那样DropDownList的有标签查看Selct2提供。

When page first renders it looks as expected the DropDownList has that tags view that Selct2 provides.

点击保存按钮,保存过程是异步不需要刷新页面完成,但选择二下拉列表失去它选择二的造型,现在只是看起来像一个普通的下拉列表。

Click the save button and the save process is done async without a page refresh, but the Select2 dropdown list loses it Select2 styling and now just looks like a regular dropdown.

如果我尝试类应用选择二到控制的CssClass属性然后在客户端上发生JavaScript错误。 不为选择二selectControlName定义未捕获的查询功能

If I try to apply the Select2 class to the CssClass property of the control then a JavaScript error occurs on the client. "Uncaught query function not defined for Select2 selectControlName"

思考?

推荐答案

由于每SELECT2设计和文档选择HTML元素不需要任何特殊的解析(数据是从选择的选项标签解析),以限制选择,只选择元素(在上述情况下的ASP.NET的DropDownList呈现为选择HTML元素)下面我推荐变化

As per the design and documentation of select2 select html element doesn't need any special parsing (data is parsed from select's option tags), to limit the selector to only select elements(in above case "ASP.NET DropDownList" renders as select html element) I recommended below change

异常通常出现比选择元素情况下,其他。

"Uncaught query function not defined for Select2" exception usually occurs for other than select element cases.

//Replace your selector by prefixing select as below and then give a try
$('select.dropdownspecificclass').select2();

这篇关于选择二JQuery的问题与ASP.NET的UpdatePanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆