jQuery Mobile Multiple Dialog Boxes in One Dialog

前端 未结 1 503
予麋鹿
予麋鹿 2021-01-07 06:47

I have searched and have not found example of doing this. I want to be able to have a dialog box open for jQM and have it where there is a step by step process that takes pl

1条回答
  •  温柔的废话
    2021-01-07 07:30

    Here is an example, using .show() and .hide(). The trick here is to create several divs, and then show/hide them.

    Working Demo

    Markup

    Dialog

    Page 1

    Text for #page1

    Page 2

    Text for #page2

    Page 3

    Text for #page3

    Code

    // hide previous button, #page2 and #page3 once opened
    $('#dialog').find('#page1 a.prev').hide();
    $('#page2, #page3').hide();
    
    // #page1 to #page2
    $('#page1 a.next').on('click', function () {
     $('#page1').hide();
     $('#page2').show();
    });
    
    // #page2 to #page3
    $('#page2 a.next').on('click', function () {
     $('#page1, #page2').hide();
     $('#page3').show();
     $('#dialog').find('#page3 a.next').hide();
    });
    
    // #page2 to #page1
    $('#page2 a.prev').on('click', function () {
     $('#page2').hide();
     $('#page1').show();
    });
    
    // #page3 to #page2
    $('#page3 a.prev').on('click', function () {
     $('#page2, #page3').hide();
     $('#page2').show();
    });
    

    0 讨论(0)
提交回复
热议问题