drqj8605 2015-01-13 09:47
浏览 65

打开后清除JQuery对话框内容

I have this code that is to open a dialog box with content generated from a php class only problem is that within 2sec the code gets clear from the dialog box. Here is the JavaScript/JQuery:

$k('#CreateTable').click(function(e){
        e.preventDefault();
         var Call =  $k('#CreateTable').attr('value');
         var util = $k(this).attr('id');//.attr('value');
        // alert(util);
         $k('#dialog').dialog({
             autoOpen: false,
            title: 'Running Utility for: '+Call,
            modal: true,
            width: 450,
            close: function(event, ui) {
            $k("#dialog").empty(); // remove the content
            }//END CLOSE
        }).dialog('open');
        $k.ajax({
                  type: "post",
                  url: "inc/runUtilities.php",
                  dataType: "html",
                  data: {
                    'utility' : util
                  },
                  success: function(data) {
                        //alert('success'); 
                        $k('#DlgTxt').html(data).fadeIn('slow');
                  }
        });
            //return false;
        });//END DIALOG

It gets triggered from the following button code:

<div class="tab-pane fade in active" id="Utilities">
          <p>
          <div>
            <button class="btn btn-lg btn-default" type="button" 
 value="Create Table" id="CreateTable" >Create Table</button>
          </p>
          </div>
       </div>

Is there something i am missing?

  • 写回答

1条回答 默认 最新

  • dongmei8460 2015-01-13 09:53
    关注

    Simply remove the ".k" will do: $.k() to $()

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
    
    <script type="text/javascript">
    $(function() {
        $('#CreateTable').click(function(e){
            e.preventDefault();
             var Call =  $('#CreateTable').attr('value');
             var util = $(this).attr('id');//.attr('value');
            // alert(util);
             $('#dialog').dialog({
                autoOpen: false,
                title: 'Running Utility for: '+Call,
                modal: true,
                width: 450,
                close: function(event, ui) {
                $("#dialog").empty(); // remove the content
                }//END CLOSE
            }).dialog('open');
            $.ajax({
                      type: "post",
                      url: "YOUR URL HERE",
                      dataType: "html",
                      data: {
                        'utility' : util
                      },
                      success: function(data) {
                            //alert('success'); 
                            $('#DlgTxt').html(data).fadeIn('slow');
                      }
            });
                //return false;
            });//END DIALOG
    });
    </script>
    </head>
    
    <body>
    <div class="tab-pane fade in active" id="Utilities">
              <p>
              <div>
                <button class="btn btn-lg btn-default" type="button" 
     value="Create Table" id="CreateTable" >Create Table</button>
              </p>
              </div>
           </div>
    </body>
    </html>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示