【问题标题】:jquery.ui dialog confirming delete not returning values to phpjquery.ui 对话框确认删除不返回值到 php
【发布时间】:2011-04-14 08:09:55
【问题描述】:

经过 4-5 小时的谷歌搜索和研究,触发表单提交不会按预期将字段值返回到 php ...感谢任何帮助

<?php   
if (isset($_POST['xxxx'])){
    echo "POST DELETE  <br />";
}else{
?>
  <div id="dialog_confirm" title="Confirm Delete">Are you sure ?</div>
  <form id='inputform' name='tablename' method='post' action='#' />
    <input type='text' name='xxxx' value='22' />
    <input type='submit' class='delete' name='delete' value='Delete' />
  </form>

  <script type='text/javascript'>
    jQuery(document).ready(function(){
       $('#inputform').submit( function(){
       $("#dialog_confirm").dialog('open'); 
          return false;
       });
       $( "#dialog_confirm" ).dialog({
          autoOpen:     false,
          resizable: false,
          height:140,
          modal: true,
          buttons: {
            "Delete all items": function() { 
              $( this ).dialog( "close" );
              window.inputform.submit();
            },
            Cancel:     function() { $( this ).dialog( "close" );}
          }
       });              
    });
  </script>

【问题讨论】:

    标签: jquery user-interface dialog confirm


    【解决方案1】:

    这是因为你有 return false;这里:

    $('#inputform').submit( function(){
           $("#dialog_confirm").dialog('open'); 
              return false;
    });
    

    因此,每当您尝试从表单提交数据时,它永远不会。您想在提交按钮上使用 click()。

    你可能想试试这个:

    $('.delete').click( function(){ //Submit button clicked (or return key pressed)
           $("#dialog_confirm").dialog('open'); 
           return false; //Don't submit the form straight away
    });
    
    $( "#dialog_confirm" ).dialog({
                resizable: false,
                autoOpen: false,
                height:140,
                modal: true,
                buttons: {
                    "Delete all items": function() {
                        $('#inputForm').submit(); //Now submit the form
                        $( this ).dialog( "close" );
                    },
                    Cancel: function() {
                        $( this ).dialog( "close" );
                    }
                }
     });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-06
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 2014-02-16
      • 2017-12-20
      • 2017-09-07
      • 1970-01-01
      相关资源
      最近更新 更多