的document.ready()回发后不工作 [英] Document.Ready() is not working after PostBack

查看:165
本文介绍了的document.ready()回发后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一个更新面板中的用户控件的页面。 $(文件)。就绪(函数()){被调用,c正确执行$ C $当网页加载首创,但如果用户点击一个按钮(内用户控制),在的document.ready()不会被调用( document.load 的onload 也不起作用)

I have a page that contains a user control within an update panel. $(document).ready(function() ) { is called and executes the code correctly when the page firsts loads but if the user clicks a button (within the user control), the document.ready() doesn't get called (document.load, onload also don't work)

我已经在网上研究,发现这个类似的问题,但没有什么可以解释为什么这是行不通的。才能有的document.ready 什么其他原因不能正常工作?

I have researched this on the net and found similar problems but nothing that can explain why this isn't working. What other causes can there be for document.ready not working?

推荐答案

这将与<一个问题href=\"http://www.asp.net/web-forms/tutorials/aspnet-ajax/understanding-partial-page-updates-with-asp-net-ajax\"相对=nofollow>部分回发。 DOM是不重新加载,因此该文件准备功能不会被再次袭来。您需要在JavaScript中分配一个局部回传处理程序是这样的...

This will be a problem with partial postback. The DOM isn't reloaded and so the document ready function won't be hit again. You need to assign a partial postback handler in JavaScript like so...

function doSomething() {
   //whatever you want to do on partial postback
}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(doSomething);

add_endRequest 上面的电话应放置在JavaScript中被执行时,第一次加载页面。

The above call to add_endRequest should be placed in the JavaScript which is executed when the page first loads.

这篇关于的document.ready()回发后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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