<small id='tel11'></small><noframes id='tel11'>

        <i id='tel11'><tr id='tel11'><dt id='tel11'><q id='tel11'><span id='tel11'><b id='tel11'><form id='tel11'><ins id='tel11'></ins><ul id='tel11'></ul><sub id='tel11'></sub></form><legend id='tel11'></legend><bdo id='tel11'><pre id='tel11'><center id='tel11'></center></pre></bdo></b><th id='tel11'></th></span></q></dt></tr></i><div id='tel11'><tfoot id='tel11'></tfoot><dl id='tel11'><fieldset id='tel11'></fieldset></dl></div>
      1. <legend id='tel11'><style id='tel11'><dir id='tel11'><q id='tel11'></q></dir></style></legend>

        <tfoot id='tel11'></tfoot>
          <bdo id='tel11'></bdo><ul id='tel11'></ul>

        带有布尔返回的 jQuery UI 对话框 - true 或 false

        时间:2023-09-04
      2. <tfoot id='j9jz9'></tfoot>

          <small id='j9jz9'></small><noframes id='j9jz9'>

            <tbody id='j9jz9'></tbody>
            <bdo id='j9jz9'></bdo><ul id='j9jz9'></ul>

          • <legend id='j9jz9'><style id='j9jz9'><dir id='j9jz9'><q id='j9jz9'></q></dir></style></legend>
              <i id='j9jz9'><tr id='j9jz9'><dt id='j9jz9'><q id='j9jz9'><span id='j9jz9'><b id='j9jz9'><form id='j9jz9'><ins id='j9jz9'></ins><ul id='j9jz9'></ul><sub id='j9jz9'></sub></form><legend id='j9jz9'></legend><bdo id='j9jz9'><pre id='j9jz9'><center id='j9jz9'></center></pre></bdo></b><th id='j9jz9'></th></span></q></dt></tr></i><div id='j9jz9'><tfoot id='j9jz9'></tfoot><dl id='j9jz9'><fieldset id='j9jz9'></fieldset></dl></div>

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

                  问题描述

                  我正在尝试替换 javascript confirm().我找到了可以完全自定义的 jquery dialog() 函数.问题是我不能让它返回 truefalse.

                  I´m trying to do an replacement for the javascript confirm(). I have found the jquery dialog() function that can be fully customized. The problem is that i cant make it return true or false.

                  这是我的代码:

                  $('#delBox').dialog(
                          { autoOpen: false, resizable: false, modal: true, closeOnEscape: true, width: 300, height: 'auto', title: 'Deletar registro',
                              buttons: {
                                  "Ok": function () {
                                      return true;
                                  }, "Cancelar": function () {
                                      $(this).dialog("close");
                                      return false;
                                  }
                              },
                              open: function () {
                                  var buttonsSet = $('.ui-dialog-buttonset').find("button:contains('Ok')");
                                  buttonsSet.attr("class", "ui-button ui-state-default");
                                  $('.ui-dialog-titlebar-close span').empty();
                                  $('.ui-dialog-buttonset').find("button:contains('Ok')").button({
                                      text: false,
                                      icons: {
                                          primary: 'ui-icon-ok'
                                      }
                                  });
                  
                                  $('.ui-dialog-buttonset').find("button:contains('Cancelar')").button({
                                      text: false, 
                                      icons: {
                                          primary: 'ui-icon-cancel'
                                      }
                                  });
                              }
                          });
                  

                  这只会在选择任何选项之前返回一个对象:

                  This only return an object before any option selected:

                  function deletar() {
                       alert($('#delBox').dialog('open'));
                  }
                  

                  推荐答案

                  jQueryUI 对话框不能返回 truefalse,因为它们显示在顶部其他内容,但没有阻塞执行.

                  jQueryUI dialog boxes can't return a true or false as they're shown on top of other content but without blocking execution.

                  你能做的最好的就是:

                  1. 将框设为modal,使其隐藏其他内容

                  根据选择的选项提供要使用的回调.

                  supply callbacks to be used depending on which option is chosen.

                  对于额外的奖励积分,您可以创建一个 $.Deferred() 承诺对象并在您显示对话框时返回它.然后,您可以在按钮事件处理程序中 resolvereject 承诺.

                  For extra bonus points, you could create a $.Deferred() promise object and return that when you show the dialog. You can then resolve or reject that promise in the button event handlers.

                  这将使您在显示对话框和执行随后由它触发的操作之间清晰地分开:

                  This would give you clean separation between showing the dialog box, and performing the actions subsequently triggered by it:

                  function showDialog() {
                     var def = $.Deferred();
                  
                     // create and/or show the dialog box here
                     // but in "OK" do 'def.resolve()'
                     // and in "cancel" do 'def.reject()'
                  
                     return def.promise();
                  }
                  
                  showDialog().done(function() {
                      // they pressed OK
                  }).fail(function() {
                      // the pressed Cancel
                  });
                  
                  // NB: execution will continue here immediately - you shouldn't do
                  //     anything else now - any subsequent operations need to be
                  //     started in the above callbacks.
                  

                  这篇关于带有布尔返回的 jQuery UI 对话框 - true 或 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:&lt;p&gt;内垂直对齐img和文本 下一篇:在 Dynamics 2011 中调用对话框并将多个记录 ID 传递

                  相关文章

                  最新文章

                1. <i id='bViji'><tr id='bViji'><dt id='bViji'><q id='bViji'><span id='bViji'><b id='bViji'><form id='bViji'><ins id='bViji'></ins><ul id='bViji'></ul><sub id='bViji'></sub></form><legend id='bViji'></legend><bdo id='bViji'><pre id='bViji'><center id='bViji'></center></pre></bdo></b><th id='bViji'></th></span></q></dt></tr></i><div id='bViji'><tfoot id='bViji'></tfoot><dl id='bViji'><fieldset id='bViji'></fieldset></dl></div>

                  <tfoot id='bViji'></tfoot>

                2. <legend id='bViji'><style id='bViji'><dir id='bViji'><q id='bViji'></q></dir></style></legend>

                  <small id='bViji'></small><noframes id='bViji'>

                    <bdo id='bViji'></bdo><ul id='bViji'></ul>