【问题标题】:jQuery+Edge Animate: Error only when called from click event: Object [object Object] has no method 'foundation'jQuery + Edge Animate:仅在从单击事件调用时出错:对象[对象对象]没有方法“基础”
【发布时间】:2013-09-06 22:44:14
【问题描述】:

在 Edge Animate 中使用 Zurb Foundation 和 jQuery 我收到此错误:

Uncaught TypeError: Object [object Object] has no method 'foundation'

....仅在从事件处理程序中调用基础函数时。在事件处理程序之外,它工作正常。

<div id="myModal" class="reveal-modal">
    <h2>Title</h2>
    <p class="lead">Description</p>
    <a class="close-reveal-modal">&#215;</a>
</div>
<a href="#" id="myButton" class="button">Click Me</a>

<script>
    $(document).foundation();

    // This works as expected
    $('#myModal').foundation('reveal', 'open');

    $("#myButton").click(function() {

        // This generates the error:
        // Uncaught TypeError: Object [object Object] has no method 'foundation'

        $('#myModal').foundation('reveal', 'open');

        return false;
    });


</script>

我该如何解决这个问题?仅当存在 Edge Animate 内容时才会出现该错误。删除后,它按预期工作。

【问题讨论】:

    标签: javascript jquery zurb-foundation adobe-edge


    【解决方案1】:

    我没有意识到 Edge 在 jQuery 版本中加载。使用 jQuery 的 noConflict() 解决了这个问题:

    <script>
        $(document).foundation();
    
        $.noConflict();
        jQuery(document).ready(function($) {
            // Code that uses jQuery's $ can follow here.
    
            // This works as expected
            $('#myModal').foundation('reveal', 'open');
    
            $("#myButton").click(function() {
                // This generates the error:
                //Uncaught TypeError: Object [object Object] has no method 'foundation'
    
                $('#myModal').foundation('reveal', 'open');
                return false;
            })
    
        });
    </script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多