jQuery Mobile Panel Swipe功能导致错误 [英] jquery mobile Panel Swipe function causing errors

查看:126
本文介绍了jQuery Mobile Panel Swipe功能导致错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很辛苦,我使用mootools制作了时钟,然后使用Yahoo API创建了一个天气小部件,现在我不知道是什么原因造成的

I'm having such a hard time, I have a flip clock using mootools, then a weather widget using Yahoo API, now I have no idea what is causing

"无法在初始化之前调用面板上的方法;试图 调用方法打开""

"cannot call methods on panel prior to initialization; attempted to call method 'open'"

我遵循此演示, http://view.jquerymobile.com/master/docs/examples/panels/panel-swipe-open.php#demo-page ,现在我得到了错误.

SO i followed this demo, http://view.jquerymobile.com/master/docs/examples/panels/panel-swipe-open.php#demo-page and now i'm getting the error.

$( document ).on( "pageinit", "#demo-page", function() {
$( document ).on( "swipeleft swiperight", "#demo-page", function( e ) {
    // We check if there is no open panel on the page because otherwise
    // a swipe to close the left panel would also open the right panel (and v.v.).
    // We do this by checking the data that the framework stores on the page element (panel: open).
    if ( $.mobile.activePage.jqmData( "panel" ) !== "open" ) {
        if ( e.type === "swipeleft"  ) {
            $( "#right-panel" ).panel( "open" );
        } else if ( e.type === "swiperight" ) {
            $( "#left-panel" ).panel( "open" );
        }
    }
});

});

我有点死了,因为我已经做到了,请随时查看我的代码, http://yaasko.com/gra423/project-4.3/如果您尝试向左或向右滑动,控制台将输出错误.

I'm sorta at a dead end cause I had it work, feel free to look at my code, http://yaasko.com/gra423/project-4.3/ if you try to swipe left or right the console will output the error.

请让我知道您是否可以帮助jquery首次移动用户!

Please let me know if you can help, first time jquery mobile user!

推荐答案

在出现此消息的情况下:

In case of this msg:

"无法在初始化之前调用面板上的方法;试图 调用方法打开""

"cannot call methods on panel prior to initialization; attempted to call method 'open'"

像这样打开面板:

$( "#left-panel" ).panel().panel("open");

第一个panel()调用将对其进行初始化,第二个将其打开.

First panel() call will initialize it and second one will open it.

$(document).on('pagebeforeshow', '#index', function(){        
    $( document ).on( "swipeleft swiperight", "#index", function( e ) {
        if ($.mobile.activePage.find('#left-panel').hasClass('ui-panel-closed') && e.type === "swipeleft") {
            $( "#right-panel" ).panel( "open" ); 
        }    

        if ($.mobile.activePage.find('#right-panel').hasClass('ui-panel-closed') &&  e.type === "swiperight") {
            $( "#left-panel" ).panel( "open" );           
        }        
    });
});

这篇关于jQuery Mobile Panel Swipe功能导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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