0

将 Zurb Foundation 和 jQuery 与 Edge Animate 一起使用,我收到此错误:

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 内容时才会出现该错误。删除后,它按预期工作。

4

1 回答 1

0

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

<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>
于 2013-09-06T23:38:19.910 回答