ASP.NET AJAX部分回发和jQuery问题 [英] ASP.NET Ajax partial postback and jQuery problem

查看:145
本文介绍了ASP.NET AJAX部分回发和jQuery问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个控件包含一些HTML和一些jQuery来处理一个奇特的提示,当你一个div中单击图像来显示。

A control contains some HTML and some jQuery to handle a fancy tooltip to display when you click an image within a div.

控制然后用几个不同的网页,有时在一个UpdatePanel,有时没有。

The control is then used on several different pages, sometimes within an updatePanel, sometimes not.

我有以下的code处理时,控制更新面板内显示的部分回发后加载jQuery的。

I have the following code to handle loading the jQuery after a partial postback when the control is displayed within an update panel.

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

   function EndRequestHandler(sender, args) {
      $('img.ormdShipping').each(function(){
            $(this).qtip({

        // some qtip options go here
        })
      });
   }

问题是,当控制比一个UpdatePanel任何地方使用其他jQuery的不加载。我需要说的触发EndRequestHandler之外的第二个功能?

Problem is, the jQuery doesn't load when the control is used anywhere other than an updatePanel. Do I need a second function that's triggered outside of the EndRequestHandler?

推荐答案

只需拨打一次页面加载,以及,你可以做到这一点通过在结尾处增加这样的:

Just call it once the page loads as well, you can do that by adding this at the end:

$(EndRequestHandler);

这将导致code运行时都一个UpdatePanel刷新,当第一次加载页面。当你在一个函数jQuery的构造函数传递,我们在调用 的jQuery(回调) 的版本,如果它更容易想想,你做的这个短版:

This will cause that code to run both when an UpdatePanel refreshes, and when the page first loads. When you pass in a function to the jQuery constructor, you're calling the jQuery(callback) version, if it's easier to think about, you're doing the short version of this:

$(document).ready(EndRequestHandler); //or..
$(document).ready(function() { EndRequestHandler(); });

这篇关于ASP.NET AJAX部分回发和jQuery问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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