1

当我在 chrome 中打开文件时,它应该如何工作,但刷新页面会给我一个错误。我已经检查过我没有两次列出相同的来源。如果你问我很奇怪!

这是我得到的错误:

未捕获的错误:无法在初始化之前调用弹出窗口上的方法;试图调用方法“打开”

<div data-role="page" id="page1">
    <div data-role="header">
        <h1>jQuery Mobile Example</h1>
    </div>
    <div data-role="content">
        <div data-role="popup" id="intro_view" data-overlay-theme="a" data-theme="a" style="max-width:100%;">
            <div data-role="header" data-theme="a" class="ui-corner-top ui-header ui-bar-a" role="banner">
                <h1 class="ui-title" role="heading" aria-level="1">Welcome!</h1>
            </div>

            <div data-role="content" data-theme="d" class="ui-corner-bottom ui-content ui-body-d" role="main">
                <h1 class="ui-title">Navigate through time and space to see what's happening around you!</h1>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Here's a few quick tips to get you started:</p>
                <ol>
                <a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="c" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-btn-inline"><span class="ui-btn-inner"><span class="ui-btn-text">Cancel</span></span></a>    
                <a href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-btn-up-b ui-shadow ui-btn-corner-all ui-btn-inline"><span class="ui-btn-inner"><span class="ui-btn-text">Delete</span></span></a>  
            </div>
        </div>
    </div>          
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $( "#intro_view" ).popup( "open",{positionTo:"window"} );
    });
</script>

4

1 回答 1

0

而不是 $(document).ready .. 使用这个

$(document).bind('pageinit', function() {
$("#intro_view").popup('open');

});

请参考 jquery 文档http://jquerymobile.com/demos/1.2.1/docs/api/events.html

于 2013-08-28T01:14:36.177 回答