Jquery Facebook 自动完成功能在更新面板回发后消失
嘿, 我在 asp.net ajax 更新面板中使用 Facebook 风格的 autoComplete, 问题是当我回发到 UpdatePanel 时,Jquery 消失了, 有什么想法吗?
谢谢,
代码:
$(document).ready(function () {
$("[id$='DDL_Guests']").fcbkcomplete({
json_url: "../../Search.asmx/SearchAC",
cache: false,
filter_case: false,
filter_hide: true,
firstselected: true,
onremove: RemoveItem,
onselect: AddItem,
filter_selected: true,
maxitems: 10,
newel: true
});
});
hey,
i'm using the Facebook style autoComplete inside a asp.net ajax update panel,
by problem is when im doing a postback to the UpdatePanel the Jquery Disapear,
Any Idead?
thanks,
Code:
$(document).ready(function () {
$("[id$='DDL_Guests']").fcbkcomplete({
json_url: "../../Search.asmx/SearchAC",
cache: false,
filter_case: false,
filter_hide: true,
firstselected: true,
onremove: RemoveItem,
onselect: AddItem,
filter_selected: true,
maxitems: 10,
newel: true
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当发生部分回发时,它会更新您的标记,因此 ID 为
DDL_Guests
的元素将不再绑定到您第一次加载页面时使用的 jQuery 代码。因此,在部分回发事件发生后,您需要重新绑定 jQuery 代码。
要解决此问题,您必须在代码中添加一个
endRequest
事件处理程序,并调用一个函数,该函数将再次将小部件重新绑定到DDL_Guests
元素,如以下代码所示然后简单地 使用此技巧从正文标记中调用
load
函数,您的 jQueryInit() 函数中的 jQuery 代码在第一次通过
$(document ).ready(function () {}
并在 UpdatePanel 引起的部分页面回发后再次重新绑定希望它有帮助
When a partial postback occurs it update your markup and so the element with ID
DDL_Guests
will not be anymore binded to the jQuery code you are using the first time the page load.So you need to rebind your jQuery code after a partial postback event has occurred.
To solve this problem you have to add an
endRequest
event handler in your code and call a function that will rebind again the widget to theDDL_Guests
element as in the following codeThen simply call the
load
function from your body markupusing this trick your jQuery code inside the
jQueryInit()
function get binded the first time the page load through the$(document).ready(function () {}
and get rebinded again after a partial page postback caused by the UpdatePanelHope it helps