【问题标题】:jquery mobile does not get the right urljquery mobile 没有得到正确的 url
【发布时间】:2014-02-10 10:02:50
【问题描述】:

每当创建按钮单击事件时,我都会获取按钮的 data-url 属性并将页面更改为该 URL。问题是页面加载了两次,url不正确,但它显示当前页面+#panel-responsive-page1(div id,我不知道它来自哪里)。

这是我的 JavaScript。我做错了什么?

jQuery( ".button" ).on( "vclick", function( ) {
            $.mobile.changePage( $(this).attr('data-url'), { transition: "slideup"} );
        });

这就是按钮的创建方式:

<button type="button" data-url="'.$button['data_url'].'" class="button data-theme-a"'.$button_class.'  >' . $button['name'] . '</button>

我也尝试过使用更改事件,但问题仍然存在。 提前谢谢。

【问题讨论】:

    标签: javascript jquery jquery-mobile mobile click


    【解决方案1】:

    尝试改变:

    data-url="'.$button['data_url'].'"
    

    到:

    data-url="'.$button["data_url"].'"
    

    【讨论】:

    • 不是这样,因为按钮接收 data-url 属性,当我签入网络时,相应的 url 给出了肯定的响应,但它加载了两次,并且 url 没有改变到它应该是什么, 但像这样:localhost/.../item.php#panel-responsive-page1 虽然页面出现(javascripts 不工作当然)
    • 我找到了另一种方法,我把按钮改成了anchor:' 。 $button['name'] 。 ' 它工作正常,但我必须修复按钮的样式。
    • 很高兴您自己找到了解决方案 :)
    猜你喜欢
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多