2013-01-15 5 views
2

유효성을 검사 할 때 웹 응용 프로그램을 개발하고 작동중인 벌금을 제출하십시오. 내가 jQuery를 대화 상자를 사용하려고하면jquery 예/아니요 대화 상자 문제

   var res = confirm ("Are u want to continue?") 
       if (res) 
       { 
        var stra_validator = $("#form").validate(form_rule); 
        stra_validator.reset(); 
        return stra_validator.form(); 

       }else{ 
        $('#someID').focus(); 
        return false; 
       } 

는하지만, 내가 제출하지 의미 다음 단계를 진행 자사 못하고이

     var btns = {}; 
         btns['Yes'] = function(){ 
          $(this).dialog("close"); 

          var stra_validator = $("#form").validate(form_rule); 
        stra_validator.reset(); 
        return stra_validator.form();// continue the process 
         }; 
         btns['No'] = function(){ 
          $(this).dialog("close"); 
            $('#someID').focus(); 
        return false; 
         }; 
         $("<div></div>").dialog({ 
         autoOpen: true, 
         title: 'Condition', 
         modal:true, 
         buttons:btns 
         }); 

처럼 사용할. 그러나 내가 아니오를 클릭하면 그것은 집중하고 있습니다. 내가 여기서 뭘 잘못 했니? 나 좀 도와 줘? 미리 감사드립니다.

답변

0

$ (this) .dialog()가 버튼 컨텍스트에서 잘못되었다고 생각합니다.

이 시도 :

var btns = {}; 
btns['Yes'] = function() { 

    // Here you have to reference the real dialog 
    $('#dialog').dialog("close"); 
    alert('come here'); 
    var stra_validator = $("#form").validate(form_rule); 
    stra_validator.reset(); 

    return stra_validator.form(); 
    // continue the process 
}; 
btns['No'] = function() { 
    $('#dialog').dialog("close"); 
    $('#someID').focus(); 

    return false; 
}; 

// Never created a div on the fly but it's working well and I just added an ID 
$('<div id="dialog"></div>').dialog({ 
autoOpen : true, 
title : 'Condition', 
modal : true, 
buttons : btns 
}); 
+0

헤이 베른 하르트, 내가 언급 한 "ID = '대화'"경고오고 있지만 여전히 같은 문제를 사용하여 빠른 응답을위한 감사합니다. $ ('# dialog').이 짝수 대화 상자가 닫히지 않은 것처럼 대화 상자 ("닫기")를 사용할 때. 감사합니다 내 경우에있어서 –

+0

흠 닫는 중이었습니다 ... – Bernhard