$(文件)。准备在ASCX页面Ajax回调后 [英] $(document).ready in ascx page after ajax callback

查看:136
本文介绍了$(文件)。准备在ASCX页面Ajax回调后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题,这种设置在这里我有一个的.ascx 文件的列表和他们都计算到控制器本身的角度做不同的任务。所以,在我的的.aspx 页我点击了 Ajax.ActionLink(),这将使得该特定的.ascx 根据我点击的项目文件。在该的.ascx 是1-3事件,将触发2都是的onclick 事件和1 的onload 。该的onclick 事件(S)是容易的工作在我而言可以硬code直接在控件事件像这样的onclick = $(#toggleMe3)的slideToggle。(慢);的onload 必须运行在的.ascx 加载我是在一个 $(文件)。准备测试这个(函数(){}); 调用,能正常工作的在的.aspx 页,但只要我尝试将其添加到的.aspx 页它不会加载它理想的,这工作,但我不知道为什么。在脚本标记其实也没什么工作,如果我直接插入到的.ascx 网​​页,他们只有工作,如果硬codeD插入控件的事件,以及他们中的一些,至少;在的onload 在prerender 不火。

I'm having a little problem with this setup here I have a list of .ascx files and they all do different tasks in terms of calculations to the controller itself. So on my .aspx page I click on an Ajax.ActionLink() and this will render that specific .ascx file based on the item I clicked. Within that .ascx are 1-3 events that will fire 2 of them are onclick events and 1 is onload. The onclick event(s) are easier to work with in terms of I can hardcode it directly in the controls event like so onclick="$("#toggleMe3").slideToggle("slow");" and the onload must run when the .ascx is loaded i was testing this in a $(document).ready(function(){}); call, this works fine in the .aspx page but as soon as I try adding it into the .aspx page it doesn't load and its ideal that this works but I have no idea why not. In fact nothing in the script tags work if I insert directly into the .ascx page they only work if hardcoded into the control's events, well some of them at least; the onload and onprerender don't fire.

推荐答案

我有同样的问题,在$(文件)指定的部分回发的脚本。就绪未执行。我发现这里的解决方案 MSDN - PageRequestManager类

I had the same problem, after partial postback script specified in $(document).ready was not executed. I found solution here MSDN - PageRequestManager Class

看起来像添加脚本如下图所示修复该问题

Looks like adding a script like below fixes the issue

<script type="text/javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(myReadyFunction);
</script>

这篇关于$(文件)。准备在ASCX页面Ajax回调后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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