ASP.NET UpdatePanel 的 Select2 JQuery 问题 [英] Select2 JQuery issue with ASP.NET UpdatePanel

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

问题描述

我被要求使用 Select2 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').select2();

当页面第一次呈现时,它看起来像预期的那样 DropDownList 具有 Select2 提供的标签视图.

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

单击保存按钮,保存过程完成async,无需刷新页面,但 Select2 下拉列表丢失了 Select2 样式和现在看起来就像一个普通的下拉菜单.

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.

如果我尝试将 Select2 类应用于控件的 CssClass 属性,则客户端上会发生 JavaScript 错误."未为 Select2 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"

想法?

推荐答案

我遇到了同样的问题.不要在 document.ready 函数中给出命令,而是在 pageLoad 函数中给出它.pageLoad 函数将在部分回发期间执行.

I had the same issue. Instead of giving the command in document.ready function, give it in pageLoad function. pageLoad function will get executed during partial post backs.

function pageLoad(sender, args) {
        $(".dropdownspecificclass").select2();
    }

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

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