javascript - 如何覆盖 jquery mobile 中链接对话框中关闭按钮的功能?

标签 javascript jquery-mobile overriding modal-dialog jquery-ui-dialog

在 jQuery Mobile 中,当进行输入并单击“下一步”按钮时,我有几个链接的对话框一个接一个地滑入/滑出。但是,每当单击对话框标题内的关闭按钮时,我都想返回到触发第一个对话框的初始页面。通常,每个对话框中的关闭按钮都会返回到触发它的页面/框。但在我的应用程序中,我需要覆盖所有这些才能返回第一页!

我的代码:

<div class="ui-block-b">
    <a data-role="button" data-theme="b" data-icon="arrow-r" data-iconpos="right" 
        data-transition="slide" href="nextpage.html" data-rel="dialog">
        next
    </a>
</div>

谢谢!

编辑:文档说

CHAINING DIALOGS: "Please note: If a dialog opens another dialog (chaining), closing the last one with a link of type data-rel="back" will always navigate to the previous dialog until the root-page of type data-role="page" is reached. This guarantees a consistent navigation between dialogs." [http://jquerymobile.com/demos/1.2.0-beta.1/docs/pages/page-dialogs.html]

最佳答案

您可以重写为对话框定义的 close 方法$.mobile.dialog.prototype.close:

<script>

    $.mobile.dialog.prototype.close = function(){

        console.log("close");

        // DO SOMETHING HERE - EX: REDIRECTING TO MAIN PAGE
        $.mobile.changePage("index.html");
    };

    $(function() {
        console.log("document loaded");         
    });

</script>

关于javascript - 如何覆盖 jquery mobile 中链接对话框中关闭按钮的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12823870/

相关文章:

jquery - 如何在移动Web应用程序中使用asp.net制作手机的通话功能

javascript - 动态限制 slider 的值

overriding - 覆盖其他类中的 puppet 变量

java - 有关方法重写的问题

javascript - msie 奇怪的 div 格式(以及其他问题)我做错了什么?

javascript - 如何在js中比较和替换一个数组中的值到另一个数组?

php - 默认情况下,WordPress 会在其 JavaScript 中公开基本 URL 吗?

javascript - CSS 中的 Circle div 无法在 Canvas 中正确显示

events - taphold jQuery Mobile 1.1.1 后触发的 tap 事件

java - 在不覆盖方法时使用 super.method() ?