jQuery中的脚本冲突 [英] Script Conflict in jQuery

查看:107
本文介绍了jQuery中的脚本冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我在asp.net中有一个用户控件,它有一个脚本块,如下所示:

Hi .
i have a user control in asp.net and It has a script block As follows :

<script language="javascript" type="text/javascript">
     function initialize<%=divResultNote.ClientID %>() {
       var divRes=$("#<%=divResultNote.ClientID %>");
       var record=<%=pCurrentRecord %>;  // From code behinde
       if (record<=0){
         showMessage(divRes,false); //if
       }
       else
       {
       showMessage(divRes,true);
       }
     }
 </script>



我的外部.js文件中也有showMessage函数,如下所示:



also i have showMessage function in my external .js file as follows :

function showMessage(divResult,isSend) {
    var divResultShow = $(divResult);
    if (isSend) {
        divResultShow.animate({
            top: "200px"
        }, 100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
        divResultShow.delay(800).fadeOut(200);
    }
    else {
        divResultShow.hide();
    }
}



.现在我想在我的任何网页中使用某些用户控件.因为我有一个UpdatePanel,这会创建部分回发,然后我使用以下代码重新绑定脚本:



. now i want to use some of this user control in my any web page . becuase i have a UpdatePanel and this Creates Partial Postback then i use follow code for rebind script :

<script type="text/javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(initialize<%=divResultNote.ClientID %>);
      </script>



但是目前,当我使用这些控件之一时,其他控件的脚本也会运行.我希望每个控件自己完成.
谢谢



but currently When I''m working with one of these controls the script of other controls run also . i want each control work by itself.
thanks

推荐答案

(#<% = pCurrentRecord%> ;; //从后台代码 如果(record < = 0){ span> showMessage(divRes,false); //if } span> 其他 span> { span> showMessage(divRes,true); } } </ 脚本 >
("#<%=divResultNote.ClientID %>"); var record=<%=pCurrentRecord %>; // From code behinde if (record<=0){ showMessage(divRes,false); //if } else { showMessage(divRes,true); } } </script>



我的外部.js文件中也有showMessage函数,如下所示:



also i have showMessage function in my external .js file as follows :

function showMessage(divResult,isSend) {
    var divResultShow =


(divResult); 如果(isSend){ divResultShow.animate({ 顶部:" }, 100 ).fadeOut( 100 ).fadeIn( 100 ).fadeOut( 100 ).fadeIn( 100 ); divResultShow.delay( 800 ).fadeOut( 200 ); } 其他 { divResultShow.hide(); } }
(divResult); if (isSend) { divResultShow.animate({ top: "200px" }, 100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); divResultShow.delay(800).fadeOut(200); } else { divResultShow.hide(); } }



.现在我想在我的任何网页中使用某些用户控件.因为我有一个UpdatePanel,这会创建部分回发,然后我使用以下代码重新绑定脚本:



. now i want to use some of this user control in my any web page . becuase i have a UpdatePanel and this Creates Partial Postback then i use follow code for rebind script :

<script type="text/javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(initialize<%=divResultNote.ClientID %>);
      </script>



但是目前,当我使用这些控件之一时,其他控件的脚本也会运行.我希望每个控件自己完成.
谢谢



but currently When I''m working with one of these controls the script of other controls run also . i want each control work by itself.
thanks


AFAIK,您不能用它来调用单个函数.

AFAIK you can''t call individual function with this.

Sys.WebForms.PageRequestManager.getInstance()


这将获得整个页面的管理器实例,而不仅仅是一个UpdatePanel.

处理程序函数确实具有sender和args参数,您可以使用它们来过滤并调用必要的函数.


This gets the instance of the manager for the entire page, not just for one UpdatePanel.

The handler functions do have a sender and args parameters that you may be able to use to filter by and call the function necessary.


这篇关于jQuery中的脚本冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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