【问题标题】:Jquery thorws error on post back when finding .dynamic function查找 .dynamic 函数时,Jquery 在回发时抛出错误
【发布时间】:2011-08-12 14:12:41
【问题描述】:

我正在使用 jquery 来显示一个工具提示弹出窗口,我正在使用的代码如下

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

            $(MainEndRequestHandler);

            function MainEndRequestHandler(sender, args) {
                loadeverthingmaster();
            }

            function loadeverthingmaster(){
                 try
                 {  

                          $(".download_now").tooltip({ 
                              effect: 'slide',
                              delay:300                                                               

                          }).dynamic({ bottom: { direction: 'down', bounce: true } });          


                       $(".help-bubble-link[title]").tooltip({

                          // tweak the position
                          offset: [10, 2],

                          // use the "slide" effect
                          effect: 'slide',

                          // add dynamic plugin with optional configuration for bottom edge
                       }).dynamic({ bottom: { direction: 'down', bounce: true } });

                 }
                 catch(err)
                 {
                     alert(err);
                 } 
            }

        </script>

但是当我加载我的页面时,我得到了这个错误

TypeError: $(".download_now").tooltip({effect: "slide", delay: 300}).dynamic 不是函数

我不知道为什么会这样。任何人都有任何想法或解决方案......

问候

【问题讨论】:

  • 这是一个格式不正确的问题。您没有告诉我们您使用的是什么插件,因此很难直接回答您。您是否尝试注释掉您的代码“$(".download_now")...” 并查看您的“$(".help-bubble-link[title]")...” 是否按预期运行?我认为您需要为第一个工具提示效果提供字符串或“标题”,因为我不认为该插件旨在与 DOM 元素一起使用。
  • 他正在使用这个库 w/ jquery flowplayer.org/tools/download/index.html

标签: jquery-ui jquery-plugins jquery jquery-selectors jquery-tooltip


【解决方案1】:

检查您导入脚本的顺序。确保此脚本标记位于 jquery-tooltip 插件导入下方。还要确保在 jquery-tooltip 插件上方导入 jquery 和 jquery-ui。此外,您可能想尝试使用 document.ready() 包装此代码,以确保所有脚本都已加载,如下所示:

<script type="text/javascript">
$(document).ready(function(){
       Sys.WebForms.PageRequestManager.getInstance().add_endRequest(MainEndRequestHandler);

            $(MainEndRequestHandler);

            function MainEndRequestHandler(sender, args) {
                loadeverthingmaster();
            }

            function loadeverthingmaster(){
                 try
                 {  

                          $(".download_now").tooltip({ 
                              effect: 'slide',
                              delay:300                                                               

                          }).dynamic({ bottom: { direction: 'down', bounce: true } });          


                       $(".help-bubble-link[title]").tooltip({

                          // tweak the position
                          offset: [10, 2],

                          // use the "slide" effect
                          effect: 'slide',

                          // add dynamic plugin with optional configuration for bottom edge
                       }).dynamic({ bottom: { direction: 'down', bounce: true } });

                 }
                 catch(err)
                 {
                     alert(err);
                 } 
            }
});
        </script>

为确保您拥有正确的库,您还可以尝试将 jquery 导入和 jquery 工具导入交换为包含 jquery + jquery 工具 + 动态插件的导入:

<!-- jQuery Library + ALL jQuery Tools -->
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>

也试试:

 $(".help-bubble-link['title']").tooltip({  //notice change in this line

                          // tweak the position
                          offset: [10, 2],

                          // use the "slide" effect
                          effect: 'slide',

                          // add dynamic plugin with optional configuration for bottom edge
                       }).dynamic({ bottom: { direction: 'down', bounce: true } });

【讨论】:

  • 所有东西都是在页面加载时第一次找到,但是在任何回发之后它都不起作用......
猜你喜欢
  • 2021-09-02
  • 1970-01-01
  • 1970-01-01
  • 2017-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-26
相关资源
最近更新 更多