jquery UI diloag

官网地址:http://api.jqueryui.com/dialog/#option-hide

 

1.简单的采用div加载

<div id="dialog">
  <form id="dialogForm" method="post" action="user/add">
   <table>
    <tr>
     <td>名字:</td>
     <td>
      <input type="text" name="name"/>
     </td>
    </tr>
    <tr>
     <td>年龄:</td>
     <td>
      <input type="text" name="age"/>
     </td>
    </tr>
   </table>
  </form>
 </div>

$("#dialog").dialog({
   modal: true,
   autoOpen: false,
   buttons:{
    "确定":function(){
     var form = $("#dialogForm");
     $.ajax({
            url:form.attr('action'),
            type:form.attr('method'),
            data:form.serialize(),
            dataType:"json",
            success:function(data){
             $("#dialog").dialog("close");
             alert("成功啦");
            },
            error:function(){
             $("#dialog").dialog("close");
             alert("出错了哦");
            }
     }
    },
    "关闭": function() {
     $("#dialog").dialog("close");
    }
   }
  });


2.jquery diloag采用动态URL的方式,需要使用iframe

  eg:

var html =
              '<div style="width:800px;height:600px;" id="dialogtest" title="Item Query">' +
              ' <iframe id="iframe" src="/app/fditemmaster/entryFdQuery" frameBorder="0" style="border:0;" scrolling="no" width="100%" height="100%"></iframe>' +
              '</div>';


                $(html).dialog({
                 bgiframe: true,
                 resizable: true,
                 width :800,
                 height:600,
                 modal: true,
                 overlay: {
                     backgroundColor: '#000',
                     opacity: 0.5
                 },
                 close:function()
                 {
                      //彻底删除div标签
                  $(this).remove();
                 }
             });

a.父窗口调用iframe中的方法

   window.frames["iframe1"].contentWindow.test();

b.iframe中调用父窗口中的方法

    window.parent.closeDialog();

c.iframe中查找父窗口中的元素

    $("body", parent.document).find('#itemId_autocomplete').attr("value",
    data);
d.父窗口中查找子窗口元素

    $('iframe').contents().find('.c_div').html();


3.相关网站链接
   http://www.cnblogs.com/mybest/archive/2011/12/02/2271940.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值