2

Webアプリを開発していますが、検証を試みて、このようなフォームを送信すると、正常に機能します。

                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;
                }

しかし、jQueryダイアログを使おうとすると、このように使用しました

                      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
                      });

次のステップに進まないということは、提出しないということです。しかし、「いいえ」をクリックすると、焦点が合っています。私がここで何を間違えたのですか?誰か助けてくれませんか?前もって感謝します。

4

1 に答える 1

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
});
于 2013-01-15T09:25:04.217 に答える