本文介绍了Jquery对话框没有返回true和false。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jquery对话框作为用户选项yes / no,并希望根据选择执行某些操作。但是对话框没有返回任何bool值。所以我使用Alert来检查值,发现警告显示[object Object]而不是true / false

I am using the Jquery dialog box for the user option yes/no and want to perform something on basis of the choice. But the dialog box is not returning any bool value. So I used Alert to check the value and found the alert displaying [object Object] instead of true/ false

$(function () {
           var $myDialog = $('#confirmDialog')
       .html('You are going to Lock the Record.<br/>Click OK to confirm.  Click Cancel to stop this action.')
       .dialog({
           autoOpen: false,
           modal: true,
           title: 'Confirm..?',
           buttons: { "OK": function () {
               $(this).dialog("close");

               return true;

           }, "Cancel": function () {
               $(this).dialog("close");

               return false;

           }
           }
       });
           $('#<%=LinkButton1.ClientID%>').click(function (e) {
               e.preventDefault();
               if (Page_ClientValidate()) {
                   var r = $myDialog.dialog('open');
                   alert(r); // To test the value returned
                   if (r == true) {
                       // To do something on the basis of the result
                   }
               }
               return false;

           });
       });

推荐答案




这篇关于Jquery对话框没有返回true和false。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 17:43
查看更多