Jquery对话框没有返回true和false。 [英] Jquery Dialog box not returning true and false.

查看:87
本文介绍了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;

           });
       });

推荐答案

(function(){
var
(function () { var


myDialog =
myDialog =


' #confirmDialog'
.html(' 你要锁定记录。< br />单击确定以确认。单击取消以停止此操作。'
.dialog({
autoOpen: false
modal: true
title:' 确认..?'
按钮:{ 确定:function(){
('#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 () {


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆