jquery之鼠标失去焦点事件
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="ctx" value="${pageContext.request.contextPath}" /> <jsp:include page="/jsp/common/header.jsp"></jsp:include> <script src="${ctx }/js/hrt/hrtMinatoSingleGoods.js"></script> <table class="queryTable" > <tr> <td class="queryTitle" width="80px">客户端</td> <td class="queryContent"> <select id="client" class="easyui-combobox" style="width: 148px" panelHeight="auto" editable="false"> <option value="">请选择</option> <option value="1" >pc</option> <option value="2">m站 app</option> </select> </td> <td class="queryTitle" width="80px">商品编码</td> <td class="queryContent"> <input class="inputText" type="text" id="goodsNo"> </td> <td class="queryBtnTd" colspan="2"> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="doQuery()">查 询</a> </td> </tr> </table> <table id="hrtMinatoSingleGoodsGrid"></table> <!-- 添加凑单商品Div --> <div id="addHrtMinatoSingleGoodsDiv" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:200px;text-align:center; background: #fafafa;"> <div class="easyui-layout" fit="true"> <div region="center" border="false" style="background:#fff;border:1px solid #ccc;"> <form id="addForm" method="POST"> <table class="queryTable" width="100%" > <tr> <td class="queryTitle" width="100">商品编码</td> <td class="queryContent" > <input class="inputText" type="text" id="addGoodsNo"> <div id="addGoodsNoMsg" style="color:#F00;display:none" ></div> </td> </tr> <tr> <td class="queryTitle" width="100">客户端</td> <td class="queryContent" > <select id="addClient" class="easyui-combobox" style="width: 100px" panelHeight="auto" editable="false"> <option value="web" >web</option> <option value="wap">wap</option> <option value="app">app</option> </select> </td> </tr> <tr> <td class="queryTitle" width="100">优先级</td> <td class="queryContent" > <input type="text" id="addGoodsOrder" min="1" precision="0" class="easyui-numberbox" style="width:100px"/> </td> </tr> <tr> <td class="queryTitle" width="100">商品描述</td> <td class="queryContent" > <input id="addGoodsNotes" class="inputText" style="width:200px"/> </td> </tr> <tr> <td class="queryTitle" width="100">商品标签</td> <td class="queryContent" > <input id="addMinatoGoodsCategoryId" class="easyui-combobox" style="width: 100px" panelHeight="auto" editable="false"> </td> </tr> </table> </form> </div> <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;"> <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="saveHrtMinatoSingleGoods('add');">保存凑单商品</a> <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="closeWin('addHrtMinatoSingleGoodsDiv');">取消</a> </div> </div> </div> <!-- 编辑凑单商品Div --> <div id="updHrtMinatoSingleGoodsDiv" class="easyui-window" title="" iconCls="icon-edit" style="width:600px; height:200px;text-align:center; background: #fafafa;"> <div class="easyui-layout" fit="true"> <div region="center" border="false" style="background:#fff;border:1px solid #ccc;"> <form id="updForm" method="POST"> <input type="hidden" id="hrtMinatoSingleGoodsIdHidden" name="hrtMinatoSingleGoodsIdHidden" value="" /> <table class="queryTable" width="100%" > <tr> <td class="queryTitle" width="100">商品编码</td> <td class="queryContent" > <input class="inputText" type="text" id="updGoodsNo"> <div id="updGoodsNoMsg" style="color:#F00;display:none" ></div> </td> </tr> <tr> <td class="queryTitle" width="100">客户端</td> <td class="queryContent" > <select id="updClient" class="easyui-combobox" style="width: 100px" panelHeight="auto" editable="false"> <option value="web" >web</option> <option value="wap">wap</option> <option value="app">app</option> </select> </td> </tr> <tr> <td class="queryTitle" width="100">优先级</td> <td class="queryContent" > <input type="text" id="updGoodsOrder" min="1" precision="0" class="easyui-numberbox" style="width:100px"/> </td> </tr> <tr> <td class="queryTitle" width="100">商品描述</td> <td class="queryContent" > <input id="updGoodsNotes" class="inputText" style="width:200px"/> </td> </tr> <tr> <td class="queryTitle" width="100">商品标签</td> <td class="queryContent" > <input id="updMinatoGoodsCategoryId" class="easyui-combobox" style="width: 100px" panelHeight="auto" editable="false"> </td> </tr> </table> </form> </div> <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;"> <a class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0);" onclick="saveHrtMinatoSingleGoods('upd');">更新凑单商品</a> <a class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0);" onclick="closeWin('updHrtMinatoSingleGoodsDiv');">取消</a> </div> </div> </div>
$(function() { createParentHiddenDom("frameName"); $('#addHrtMinatoSingleGoodsDiv').window('close'); $('#updHrtMinatoSingleGoodsDiv').window('close'); $("#hrtMinatoSingleGoodsGrid") .datagrid( { url : appPath + '/page/hrtMinatoSingleGoods/getHrtMinatoSingleGoods', height : 'full', striped : true, remoteSort : false, pagination : true, rownumbers : true, singleSelect : false, queryParams : getQueryParam(), frozenColumns : [ [ { field : 'ck', checkbox : true }, { field : 'opt', title : '操作', width : 40, align : 'center', formatter : function(value, rowData, rowIndex) { var html = "<img class='op-enable' src='" + appPath + "/js/lib/jquery-easyui/themes/icons/pencil.png' onClick='opreateHrtMinatoSingleGoods(\"" + rowData.id + "\")' title='编辑'/>"; return html; } } ] ], columns : [ [ { field : 'goodsNo', title : '商品编号', width : 100, align : 'left', sortable : true }, { field : 'productName', title : '商品名称', width : 200, align : 'left', sortable : true }, { field : 'ecPrice', title : '商品价格', width : 100, align : 'left', sortable : true }, { field : 'goodsNotes', title : '商品描述', width : 150, align : 'left', sortable : true }, { field : 'goodsOrder', title : '优先级', width : 100, align : 'left', sortable : true }, { field : 'mul', title : '客户端', width : 100, align : 'left', sortable : true }, { field : 'minatoGoodsCategoryName', title : '商品标签', width : 100, align : 'left', sortable : true }, { field : 'addTime', title : '添加时间', width : 150, align : 'left', sortable : true }, ] ], toolbar : [ { id : 'btnadd', text : '添加凑单商品', iconCls : 'icon-add', handler : function() { // 清空表单 $('#addForm').form('clear'); // 设置客户端选中项 $('#addClient').combobox("select", 'web'); // 绑定商品编号失去焦点事件 goodNoBlur('add'); getMinatoSingleGoodsCategorys("add"); $('#addHrtMinatoSingleGoodsDiv').window({ title : '添加凑单商品', iconCls : 'icon-add', width : 450, height : 250, left : 550, top : 150, modal : true, shadow : true, collapsible : false, minimizable : false, maximizable : false }); } }, "-", { id : 'btnPass', text : '批量删除', iconCls : 'icon-ok', handler : function() { deleteHrtMinatoSingleGoods(); } } ] }); }); /** * 查询 */ function doQuery() { $("#hrtMinatoSingleGoodsGrid").datagrid('load', getQueryParam()); } /******************************************************************************* * 获得参数 */ function getQueryParam() { var HrtMinatoSingleGoods = new Object(); HrtMinatoSingleGoods.mul = $("#client").combobox( "getValue"); if ($("#goodsNo").val()) { HrtMinatoSingleGoods.goodsNo = $("#goodsNo").val(); } return HrtMinatoSingleGoods; } /******************************************************************************* * 显示凑单信息 */ function opreateHrtMinatoSingleGoods(hrtMinatoSingleGoodsId) { getMinatoSingleGoodsCategorys("upd"); doAjax({ url : appPath + '/page/hrtMinatoSingleGoods/opreateHrtMinatoSingleGoods/' + hrtMinatoSingleGoodsId, type : 'post', dataType : "json", success : function(data) { // 凑单商品Id $("#hrtMinatoSingleGoodsIdHidden").val(data.id); // 商品编号 $("#updGoodsNo").val(data.goodsNo); // 客户端 $('#updClient').combobox("select", data.mul); // 优先顺 $('#updGoodsOrder').val(data.goodsOrder); // 商品描述 $("#updGoodsNotes").val(data.goodsNotes); // 商品标签 $('#updMinatoGoodsCategoryId').combobox("select", data.minatoGoodsCategoryId); $('#updHrtMinatoSingleGoodsDiv').window({ title : '修改凑单商品', iconCls : 'icon-edit', width : 450, height : 250, left : 550, top : 150, modal : true, shadow : true, collapsible : false, minimizable : false, maximizable : false }); $('#updHrtMinatoSingleGoodsDiv').window('open'); // 绑定商品编号失去焦点事件 goodNoBlur('upd'); }, error : function(XMLHttpRequest, textStatus, errorThrown) { $.messager.alert('提示信息', '抱歉,保存失败,' + textStatus, 'error'); } }); } /** * 保存凑单商品(添加、更新) */ function saveHrtMinatoSingleGoods(type) { if ($('#' + type + 'GoodsNo').val() == "" || $('#' + type + 'GoodsNoMsg').html() != "") { $.messager.alert("提示", "请输入正确的商品编号!", "info"); return; } else if (!$('#' + type + 'GoodsOrder').val()) { $.messager.alert("提示", "请输入优先级!", "info"); return; } console.log($("#" + type + "MinatoGoodsCategoryId").combobox("getValue")); if($("#" + type + "MinatoGoodsCategoryId").combobox("getValue")=="--请选择--" || $("#" + type + "MinatoGoodsCategoryId").combobox("getValue")=="0"){ $.messager.alert("提示", "请选择商品标签!", "info"); return; } // 商品编号 var goodsNo = $.trim($('#' + type + 'GoodsNo').val()); // 客户端 var client = $("#" + type + "Client").combobox("getValue"); // 优先级 var goodsOrder = $('#' + type + 'GoodsOrder').val(); // 商品描述 var goodsNotes = $.trim($('#' + type + 'GoodsNotes').val()); var hrtMinatoSingleGoods = new Object(); // 商品标签 var minatoGoodsCategoryId = $("#" + type + "MinatoGoodsCategoryId").combobox("getValue"); // 更新的场合,设置凑单商品Id if (type == 'upd') { hrtMinatoSingleGoods.id = $("#hrtMinatoSingleGoodsIdHidden").val(); } hrtMinatoSingleGoods.goodsNo = goodsNo; hrtMinatoSingleGoods.mul = client; hrtMinatoSingleGoods.goodsOrder = goodsOrder; hrtMinatoSingleGoods.goodsNotes = goodsNotes; hrtMinatoSingleGoods.minatoGoodsCategoryId = minatoGoodsCategoryId; doAjax({ url : appPath + "/page/hrtMinatoSingleGoods/saveHrtMinatoSingleGoods", type : 'post', data : hrtMinatoSingleGoods, success : function(data) { switch (data) { case "ok": if (type == 'add') { $.messager.alert('提示信息', '保存成功', 'info'); } else { $.messager.alert('提示信息', '更新成功', 'info'); } break; default: $.messager.alert('提示信息', '抱歉,失败了', 'error'); break; } $('#' + type + 'HrtMinatoSingleGoodsDiv').window('close'); doQuery(); return; }, error : function(XMLHttpRequest, textStatus, errorThrown) { $.messager.alert('提示信息', '抱歉,保存失败,' + textStatus, 'error'); } }); } // 批量删除推荐商品 function deleteHrtMinatoSingleGoods() { var selections = $("#hrtMinatoSingleGoodsGrid").datagrid('getSelections'); if (selections == null || selections == '') { $.messager.alert('提示信息', '请选操作的记录', ''); return; } else { var hrtMinatoSingleGoodsIds = ''; for (var i = 0; i < selections.length; i++) { hrtMinatoSingleGoodsIds += selections[i].id + ','; } hrtMinatoSingleGoodsIds = hrtMinatoSingleGoodsIds.substring(0, hrtMinatoSingleGoodsIds.lastIndexOf(',')); $.messager .confirm( '提示信息', "您确定批量删除凑单商品?", function(r) { if (r) { doAjax({ url : appPath + "/page/hrtMinatoSingleGoods/deleteHrtMinatoSingleGoods", type : 'post', data : {"hrtMinatoSingleGoodsIds":hrtMinatoSingleGoodsIds}, success : function(data) { switch (data) { case "ok": $.messager .alert('提示信息', '删除成功', ''); break; default: $.messager.alert('提示信息', '抱歉,失败了', 'error'); break; } doQuery(); return; }, error : function(XMLHttpRequest, textStatus, errorThrown) { $.messager.alert('提示信息', '抱歉,删除失败,' + textStatus, 'error'); } }); } }); } } /******************************************************************************* * 绑定goodNo失去焦点后,查询商品编号事件 */ function goodNoBlur(type) { var goodsNo = $('#' + type + 'GoodsNo'); var goodsNoMsg = $('#' + type + 'GoodsNoMsg'); goodsNo.blur(function() { if (goodsNo.val() == '') { goodsNoMsg.html(''); return; } doAjax({ url : appPath + "/page/hrtMinatoSingleGoods/" + goodsNo.val() + "/checkGoodNo", success : function(data) { if (data == 'error') { goodsNoMsg.css('display', 'inline'); goodsNoMsg.html('该商品编号不存在'); } else { goodsNoMsg.css('display', 'none'); goodsNoMsg.html(''); } } }); }); } function getMinatoSingleGoodsCategorys(type){ $("#"+type+"MinatoGoodsCategoryId").combobox({ url:appPath + "/page/hrtMinatoSingleGoods/getAllMinatoGoodsCategorys", valueField:"id", textField:"name" }); $("#"+type+"MinatoGoodsCategoryId").combobox("select", '--请选择--'); } /** * 关闭窗口 */ function closeWin(dlg) { $('#' + dlg).window('close'); }
jquery之鼠标失去焦点事件的更多相关文章
- jquery获取焦点和失去焦点事件代码
input失去焦点和获得焦点 鼠标在搜索框中点击的时候里面的文字就消失了. 我们在做网站的时候经常会用到搜索框的获得焦点和失去焦点的事件,因为懒,每次都去写非常的烦,于是就一劳永逸,遇到类似情况就来调 ...
- Knockout: 实践CSS绑定和jQuery的blur失去焦点事件, 给未通过校验的输入框添加红色边框突出显示.
目的: 实践一下Knockout提供的CSS绑定功能和JQuery的blur失去焦点事件, 这次不使用Knockout的afterkeydown事件了. 步骤: 先在htm中添加.error的css样 ...
- jQuery模拟鼠标点击事件失效的问题
最近使用jQuery操作浏览器获取数据,需要对分页的信息进行处理,发现直接使用$('div#pager a.next').click();的这种写法无法触发点击事件. 使用trigger('click ...
- jquery的鼠标移入移出事件hover、mouseenter、mouseleave、mouseover、mouseout
hover:鼠标进入元素的子元素时不会触发‘鼠标移开’的事件: mouseenter.mouseleave:效果与hover相同: mouseover: 鼠标进入元素和进入它的子元素时都会触发‘mou ...
- JavaScript与jQuery关于鼠标点击事件
即实现鼠标点击其中一个菜单发生样式的改变,当点击下一个菜单时,当前菜单样式改变,其他菜单均变为之前样式. 用JavaScript,jQuery都可以实现,只是后者是封装的JavaScript库,具有s ...
- onblur鼠标失去焦点事件
- Knockout: 使用CSS绑定和event的blur失去焦点事件, 给未通过校验的输入框添加红色边框突出显示.
目的:使用knockout提供的机制实现输入框失去焦点后的校验工作,并使用CSS绑定给未通过校验的输入框添加红色边框突出显示. 步骤: 先在htm中添加.error的css样式, 并在输入框中的dat ...
- jquery 触发/失去焦点事件例子详解
触发焦点: $("Element").focus() 触发每一个匹配元素获得焦点事件. $("Element").focus(function) 事件会在获得焦 ...
- jquery div 下拉框焦点事件
这章与上一张<jquery input 下拉框(模拟select控件)焦点事件>类似 这章讲述div的焦点事件如何使用 div的焦点事件与input的焦点事件区别在于 需要多添加一个属性: ...
随机推荐
- vsftp关于"550 create directory operation failed"问题解决
前提: 昨天晚上配置好了vsftp, 但登陆后,除了浏览,什么也干不了.(如新建文件/文件夹, 删除文件, 重命名等都不可操作) 都是弹出 "550 create directory ope ...
- Python 中 open()文件操作的方式
Python的open方法用来打开一个文件.第一个参数是文件的位置和文件名,第二个参数是读写模式: f=open('/1.txt','w') 读写模式的类型有: rU 或 Ua 以读方式打开, 同时提 ...
- MySQL REPLACE替换输出
原输出: [root@ARPGTest ~]# mysql -p`cat /data/save/mysql_root` pro_manager -e'select erlang_script,sql_ ...
- Objective-C 笔记 字符串操作
这次总结下OC里一些对字符串的一些操作. 创建字符串对象时,会创建一个内容不可更改的对象,称为不可变对象.可以使用NSString类处理不可变字符串.你经常需要处理字符串并更改字符串中的字符.例如,可 ...
- C#垃圾回收
析构方法: 我们知道引用类型都有构造方法(constructor),相对应的也有一个析构方法(destructor).顾名思义,构造方法,就是在创建这个对象时,要执行的方法.例如,我们可以通过构造方法 ...
- VS2013打包与部署
近期做一个配置工具,完事了想打包一下:由于用的是VS2013:与之前的略有不同,简单的做了一下,在这里分享一下,直接看吧: 首先 是自己新建一个项目 ,我的WPF应用程序 第二步:右键解决方案添加新 ...
- JQuery 解析xml
JQuery 可以通过 $.get() 或 $.post() 方法来加载 xml. JQuery 解析 XML 与解析 DOM 一样, 可以使用 find(), children() 等函数来 ...
- win7下搭建nginx+php的开发环境
本来在win7下用的是IIS做web服务器,但近来因项目需求的原因,需要在服务器遇到404错误的时候自动做转向(不是在客户端的跳转,而是在服务器收到客户端请求去某目录下读取文件返回时,如果发现目录或目 ...
- 使用微软 AppFabric 遇到问题
我做的一个项目用了,但是遇到很奇怪的问题,在测试环境下,两台机做集群,一切正常,达到设计要求,但是部署到专用网络(内部网络,无法访问internet),老是提示访问服务器超时,初步排查,发现貌似是域的 ...
- php 基于phpexcel制作的导出excel类
最近要写个项目,由于项目中导出excel太多,因此写个类便于使用. <?php /**如果是gbk的编码,请转为UTF8 *@使用方法. *引入类库. * $excel = news excel ...