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.asm开发者_StackOverflow社区x/SearchAC",
cache: false,
filter_case: false,
filter_hide: true,
firstselected: true,
onremove: RemoveItem,
onselect: AddItem,
filter_selected: true,
maxitems: 10,
newel: true
});
});
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 the DDL_Guests
element as in the following code
$(document).ready(function () {
jQueryInit();
});
function load() {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(jQueryInit);
}
function jQueryInit() {
$("[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
});
}
Then simply call the load
function from your body markup
<body onload="load()">
using 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 UpdatePanel
Hope it helps
精彩评论