我有一部分 JavaScript 在文档准备就绪时运行。但是,当我使用 telerik 的过滤时,成功过滤后,文档就绪的功能未被注册。
$(document).ready(function () {
// Match all link elements with href attributes within the content div
$('#image1').qtip({
content: {
text: true
},
style: {
classes: 'qtip-rounded qtip-shadow',
},
position: {
my: 'top center', // Position my top left...
at: 'bottom center', // at the bottom right of...
target: $('.selector') // my target
}
//position: {
// target: 'mouse',
//}
});
});
当我们点击telerik提供的过滤的任何下拉值时,是否会调用 telerik 的任何功能。如果是这样,我可以从代码隐藏中注册javascript函数。或者,如果我可以通过任何其他方法得到承认。
答案 0 :(得分:2)
如果您正在使用 Telerik Ajax Controls for ASP.NET ,则过滤后会发出回发(或异步回发),这是正常行为。 由于Microsoft Ajax的工作方式,jQuery的ready函数无法拦截Ajax异步回发。
$(function(){
//this will only be triggered on the response to the first request
});
您应该使用Microsoft Ajax语法来拦截Ajax响应......
var mngInstance = Sys.WebForms.PageRequestManager.getInstance();
mngInstance.add_endRequest(endReq);
mngInstance.add_pageLoaded(pageLoaded);
function endReq(sender, args){
//executes after an async request ends
}
function pageLoaded(sender, args){
//executes after the whole page is loaded after an async postback
}
请注意,您需要RadScriptManager
到页面(或母版页)。
有关更多信息,请查看MSDN documentation