javascript函数调用根据其他控件事件触发 [英] javascript function call according to other controls event fire

查看:70
本文介绍了javascript函数调用根据其他控件事件触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我使用的是asp:updatepanel,asp:updatepanel包含imageslider,gridview等

我正在调用javascript在pageload()中的函数用于维护imageslider的阶段,但每次imagelider进入它的起始位置,如:

Hello,

I am using asp:updatepanel, asp:updatepanel contains imageslider, gridview etc.
and i am calling javascript function in pageload() for maintain the stage of imageslider but every time imageslider comes in it's starting position, like:

function pageLoad()
                {
                $(function () {
                $('#mycarousel').jcarousel();
                });
                }





这就是为什么我想根据gridview eventfire调用此函数或任何其他选项来调用Jcarousel() gridview控件ID。



请帮助



谢谢

Shubham Gupta



that's why i want to call this function according to gridview eventfire or any other option to call Jcarousel() according gridview control ID.

please help

Thanks
Shubham Gupta

推荐答案

(function(){
(function () {


' #mycarousel')。jcarousel();
});
}
('#mycarousel').jcarousel(); }); }





这就是为什么我想根据gridview eventfire调用此函数或任何其他选项来调用Jcarousel() gridview控件ID。



请帮助



谢谢

Shubham Gupta



that's why i want to call this function according to gridview eventfire or any other option to call Jcarousel() according gridview control ID.

please help

Thanks
Shubham Gupta


您好,



您的代码的主要问题是您使用的是jQuerys ready方法 [ ^ ]。 NET的UpdatePanel控件。



这意味着,您的jQuery方法将在第一次加载页面时运行(并且DOM已准备就绪),但此事件不会在发生部分回发。



有几种方法可以解决这个问题,大多数方法都需要连接WebForms PageRequestManagers endRequest事件 [ ^ ]到jQuery的ready函数。



在你的实例中,这看起来像是:

Hi,

The main problem area with your code is that you are using jQuerys ready method[^] with ASP.NET's UpdatePanel control.

This means, your jQuery method will run the 1st time your page is loaded (and the DOM is ready), but this event will not fire when a partial postback occurs.

There are a few methods to handle this, most involve wiring up the WebForms PageRequestManagers endRequest Event[^] to the jQuery's ready function.

In your instance, this would look something like:
//Your JS function ... 
function doCarousel(){


这篇关于javascript函数调用根据其他控件事件触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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