I have a pageLoad function which sets some css on an .ascx control that I cannot change. On page load everything is fine, but when an update panel updates the control, my css is no longer applied. How can I rerun my function after the page updates?

我有一个pageLoad函数,它在.ascx控件上设置一些css,我无法更改。在页面加载时,一切正常,但是当更新面板更新控件时,我的css将不再被应用。如何在页面更新后重新运行我的函数?

 $(function() {
        $("textarea").attr("cols", "30");
        $("input.tbMarker").css({ "width": "100px" }).attr("cols","25");
    });

This obviously only runs on the initial page load. How can I run it after an update?

这显然只在初始页面加载时运行。更新后如何运行它?

5 个解决方案

#1


38

Adding an add_pageLoaded handler can also work.

添加一个添加了页面的处理程序也可以工作。

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler);

Note: the handler will fire for any callback, but you can use sender._postBackSettings.panelID to filter when you want your function called.

注意:处理程序将会触发任何回调,但是您可以使用sender._postBackSettings。当需要调用函数时,可以使用panelID进行筛选。

More samples:

更多的样本:

  • http://blog.jeromeparadis.com/2007/03/01/1501/
  • http://blog.jeromeparadis.com/2007/03/01/1501/
  • http://zeemalik.wordpress.com/2007/11/27/how-to-call-client-side-javascript-function-after-an-updatepanel-asychronous-ajax-request-is-over/
  • http://zeemalik.wordpress.com/2007/11/27/how-to-call-client-side-javascript-function-after-an-updatepanel-asychronous-ajax-request-is-over/

更多相关文章

  1. 使用jQuery.ajax post函数将javascript数组中的数据传递给服务器
  2. 重写ajax方法实现异步请求session过期时跳转登录页面
  3. TypeError:e。getPosition不是一个函数。
  4. [jquery]如何实现页面单块DIV区域滚动展示
  5. 基于Jquery ui 可复用的酒店 web页面选择入住日期插件
  6. 在ASPX页面中使用webmethod服务AJAX请求。
  7. JQuery Mobile 手机显示页面偏小
  8. jquery的$.alerts.alert怎么实现点击后跳转页面
  9. 记录前台页面一些jQuery笔记

随机推荐

  1. android 竖屏拍照旋转90度
  2. Android Studio 中gradle产生的一个错误
  3. ListView使用完全讲解
  4. Android(安卓)VideoView播放视频
  5. Android API开发之TTS开发之Android TTS
  6. Android处理EditText键盘自动隐藏
  7. Android开发艺术探索 第2章 IPC机制(部分
  8. Android中判断网络功能是否可用
  9. Android 系统字体和颜色样式
  10. Android(安卓)面试题及答案(英文)