2012-11-02 3 views
1

내 JQuery 대화 상자의 "확인"버튼을 클릭하면 다른 페이지로 리디렉션하려고합니다. JQuery 함수가 JavaScript 함수에 의해 정의 된 대화 상자에 액세스 할 수없는 것처럼 보입니다. 어떤 도움을 주시면 감사하겠습니다! 여기에 내 코드입니다 :다른 함수에서 열린 JQuery 대화 상자 조작

$('#submitRegistration').bind('click', function() { 
    $.post('verification/register.php', $('#register').serializeArray(), function(data){ 
     switch (data) { 
      case "errMod": 
       showDlg("Your attempt has been recorded. Expect the po-po any day now!"); 
       break; 
      case "err1": 
       showDlg("Username Incorrect", "The username must be at least 6 characters long"); 
       break; 
      case "err2": 
       showDlg("Password Incorrect", "Password must be at least 8 characters long"); 
       break; 
      case "err3": 
       showDlg("Database Offline", "The database is offline. Please try again later."); 
       break; 
      case "err4": 
       showDlg("Not Unique Username", "Username has already been taken. Please choose another one"); 
       break; 
      case "noerr": 
       showDlg("Success!", "You have been registered! Click OK to continue"); 

        while($('#message').dialog('isOpen')) { 
         continue; 
        } 
          window.location = 'none.php'; 
          break; 
       default:      
      } 

     }); 



}); 

function showDlg(head, contents) { 
     $('#message').html(contents); 
     $('#message').dialog({        
      title: head, 
      modal: true, 
      dragable: false, 
      //resizable: false, 
      show: 'slide', 
      hide: 'slide', 
      buttons: { 
       'OK': function() { $('#message').dialog('close'); } 
      } 
     }); 
    } 

답변

0

는 다음을 사용하여 시도 할 수 jquery-ui

<!doctype html> 

<html lang="en"> 
<head> 
    <meta charset="utf-8" /> 
    <title>jQuery UI Dialog - Modal message</title> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> 
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script> 
    <script src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script> 
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script> 
    <link rel="stylesheet" href="/resources/demos/style.css" /> 
    <script> 
    $(function() { 
     $("#dialog-message").dialog({ 
      modal: true, 
      buttons: { 
       Ok: function() { 
        $(this).dialog("close"); 
       } 
      } 
     }); 
    }); 
    </script> 
</head> 
<body> 

    <div id="dialog-message" title="Download complete"> 
    <p> 
     <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span> 
     Your files have downloaded successfully into the My Downloads folder. 
    </p> 
    <p> 
     Currently using <b>36% of your storage space</b>. 
    </p> 
</div> 

<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p> 


</body>