sasori
sasori

Reputation: 5455

jquery modal confirm box button functionality, help please?

I have a jquery modal confirm-box, I added a register and login button ( i just copied the one from the manual )..now the problem is,

1) once I click the register button, I want to show another Pop-up box, and this pop-up, shall contain this ajax powered module

          <div id="registerpopup">
            <?php
            if($_GET['t']=='l')
                {
                    $the_class->Lostpword('pword_embed');
                }
            elseif($_GET['t']=='b')
                {
                    $the_class->Lostpword('unamepword_embed');
                }
            elseif($_GET['t']=='n')
                {
                    //$the_class->Lostpword('pword_embed');
                    $the_class->Registration('unamepword_embed_next');
                }
            elseif($_GET['t']=='r')
                {
                    //$the_class->Lostpword('pword_embed');
                    $the_class->Registration('register_embed');
                }
            else
                {
                    $the_class->Lostpword('accn_help');
                }
                ?>
          </div>

2 ) then once that ajax powered module pop up appeared, the confirm-box closes.
3 ) when the user registered successfully, how to close this new pop-up and refresh the page automatically, because every registered users in my app should be automatically logged-in.

here's my confirm-box code

 if(userid == ""){
        $( "#dialog:ui-dialog" ).dialog( "destroy" );

        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height: 230,
        width: 350,
            modal: true,
            buttons: {
                "Register": function(){
                $(this).dialog("close");
                },
                "Log in": function() {
                    $(this).dialog("close");
                }
            }
        });
    return false;
 }

Upvotes: 1

Views: 379

Answers (1)

SeanCannon
SeanCannon

Reputation: 77966

// Inside confirm modal code
// On click of register button...
$('#confirm_register_btn').click(function(){
    // ... close the confirm box
    $('#confirm_box').hide();
});

// Inside register modal code
$.ajax({
    url: '/path-to-register.php',
    data: ...
    dataType: ...
    type: 'post',
    success:function(data){
        // Example, data = 'Registration successful'
        // Let the user know...
        $('body').html(data + ' -- Please wait while we redirect you');

        // Reload page
        window.location.reload();
    }
});

Upvotes: 1

Related Questions