easyui04

1.dialog组件的使用
    类似Bootstrap中的模态框

<div id="dd" style = "display:none"></div> 
$('#dd').dialog({    
    title: '新增图书',    
    width: 400,    
    height: 250,    
    closed: false,    
    cache: false,    
    href: xPath+'/editBook.jsp',//新增的表单页面    
    modal: true,
    buttons:[{
    text:'保存',
    handler:function(){
        //ajax方法传递数据到servlet中
        $.post("add路径",$("表单id").serialize(),function(data){
            if(data.success){
                $.messager.alert('我的消息','这是一个提示信息!');


            }
        });
    }
    },{
    text:'关闭',
    handler:function(){...}
    }]   
});    
 

2.$("表单id").serialize()
    jQuery中提供的一个方法,可以直接不需要手动获取输入框值,直接打包形成一个url参数拼接。

3.消息框的使用
    $.message.alert();

4.

	$('#dd').dialog({    
		    title: '新增图书',    
		    width: 400,    
		    height: 260,    
		    closed: false,    
		    cache: false,    
		    href: xPath+'/addBook.jsp',    
		    modal: true ,
		    buttons:[{
				text:'新增',
				handler:function(){
					$.ajax({
						url:xPath+"/addBook",
						type:"post",
						data:$('#bookForm').serialize(),//获取表单中的值
						datatype:"text",
						success:function(data){
							let flag=data.message;
							if(flag){
								$.messager.alert('我的消息','新增成功!');
								myload();//刷新界面,
								$('#dd').dialog('close');//关闭界面
							}
						}
					});
				}
			},{
				text:'关闭',
				handler:function(){
					$('#dd').dialog('close');
				}
			}]
		});   

 以上代码弹出对话框窗口

url属性引入表单,代码如下

<div>
	<form id="bookForm">   
		<input type="hidden" name="bid" id="bid"/>
	    <div style="margin: 15px;">   
	        <label for="name">书名:</label>   
	        <input id = "bookname" class="easyui-textbox" name="bname"  style="width:300px" data-options="required:true"> 
	    </div>   
	    <div style="margin: 15px;">   
	        <label for="price">价格:</label>   
	        <input class="easyui-textbox" name="bprice"  style="width:300px" data-options="required:true"> 
	    </div>
	    <div style="margin: 15px;">   
	        <label for="booktype">类型:</label>   
	        <input class="easyui-textbox" name="btype" style="width:300px" data-options="required:true"> 
	    </div>  
	</form>
	</div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值