jquery-ui弹框问题($('#editdetaildiv').dialog('open')第二次不弹框)问题解决给分结贴

魔鬼_ 2015-08-19 05:31:40
我的一个list.jsp文件引入了如下内容
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-ui-1.8.18.custom.min.js"></script>
<link rel="stylesheet" href="${pageContext.servletContext.contextPath }/css/jquery-ui-1.8.18.custom.css">
<link rel="stylesheet" href="${pageContext.servletContext.contextPath }/notebook/notebook_files/bootstrap.css">

<link rel="stylesheet" href="${pageContext.servletContext.contextPath }/js/ZebraDatepicker/public/default.css">
<link rel="stylesheet" href="${pageContext.servletContext.contextPath }/js/ZebraDatepicker/public/reset.css">
<link rel="stylesheet" href="${pageContext.servletContext.contextPath }/js/ZebraDatepicker/public/style.css">

<script type="text/javascript" src="${pageContext.request.contextPath}/js/ZebraDatepicker/core.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/ZebraDatepicker/zebra_datepicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/businessmana/confirmationmana/list.js"></script>
其中此list.jsp文件中有一个div用来做弹出框用的代码如下(crazy标签是自定义的这个没有问题):
<div id="editdetaildiv" >
<table>
<tr>
<td>货物名称:</td><td><crazy:dictselect id="cargoname" name="cargoname" collection="${showcargoinfos}" ></crazy:dictselect></td>
</tr>
<tr>
<td>货物数量:</td><td> <input id="cargocount" name="cargocount" /> </td>
</tr>
<tr>
<td>货物重量:</td><td><input id="cargoweight" name="cargoweight" type="text"/> </td>
</tr>
<tr>
<td>数量单位:</td><td><crazy:dictselect id="showcountorginfos" name="showcountorginfos" collection="${showcountorginfos }"/></td>
</tr>
<tr>
<td>含 菌 数 :</td><td> <input id="funguscount" name="funguscount" type="text" /> </td>
</tr>
<tr>
<td>要求剂量 :</td><td> <input id="reqreagent" name="reqreagent" type="text" /> </td>
</tr>
<tr>
<td>辐照方式 :</td><td><crazy:dictselect id="irradtypes" name="irradtypes" collection="${irradtypes }"/></td>
</tr>
<tr>
<td>辐照时间 :</td><td> <input id="irradtime" name="irradtime" type="text" /> </td>
</tr>
<tr>
<td>时间单位 :</td><td> <crazy:dictselect id="timeorgs" name="timeorgs" collection="${timeorgs }"/> </td>
</tr>
<tr>
<td>备注信息:</td><td><crazy:dictselect id="irradflags" name="irradflags" collection="${irradflags }"/></td>
</tr>
<tr>
<td>其他说明:</td><td> <input id="irradflag" name="irradflag" type="text" /> </td>
</tr>
</table>
</div>
list.js这个文件部分代码如下(关于弹出框的):
这个是定义:
$("#editdetaildiv").dialog({
autoOpen : false,// 设置对话框打开的方式 不是自动打开
show : "bind",
hide : "explode",
modal : true,
height : 500,
width : 450,
buttons : {
'保存' : function() {
saveEditdetailInfo();
$(this).dialog("close");
},
"取消" : function() {
$(this).dialog("close");
}
},
open : function(ev, ui) {
initEditConfirmInfo();
// CommnUtil.cleanInputValue("addcargoname,org,irradtype,irradtime,timeorg");
},
close : function(ev, ui) {
//CommnUtil.cleanInputValue("cargoname,cargocount,cargoweight,showcountorginfos,funguscount,reqreagent,irradtypes,irradtime,timeorgs,irradflags,irradflag");
}
});
单击jsp中的一个按钮触发的弹框代码:
function processeditdetail(){
if(CommnUtil.isHaveSelectOneCheckbox("confirmsDetailcheck")){
alert("processeditdetail");
$('#editdetaildiv').dialog('open');
}else{
alert("请选择而且只能选择一条详情记录!");
}
}
我的问题如下:
第一次进入list.jsp页面单击写好的触发弹框按钮没有任何问题。弹框正常,但是换到其他页面在回到list.jsp这个页面在此单击触发弹框的按钮,页面不会弹出对话框,这行代码:
alert("processeditdetail");能正常执行,
但是$('#editdetaildiv').dialog('open');这行代码没有反应。
万能的吧友,求解脱。。。
...全文
799 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
魔鬼_ 2015-08-19
  • 打赏
  • 举报
回复
引用 9 楼 shijing266 的回复:
我猜应该是第二次访问这个页面的时候,有两种可能 1、页面没有加载到这段js, 但是你既然能访问alert()的两句,那证明没问题 2、这个ID获取的这个对象undefined了 看看这个
解决了。。。和你说的一样第二次没有加载dialog的初始化,所以我写了2次初始化,但是原理很模糊,先不管了。代码如下: //用于第二次初始化 $("#editconfirmdetaildiv").dialog({ autoOpen : false,// 设置对话框打开的方式 不是自动打开 show : "bind", hide : "explode", modal : true, height : 500, width : 450, title: "编辑", buttons : { '保存' : function() { saveEditdetailInfo(); $(this).dialog("close"); }, "取消" : function() { $(this).dialog("close"); } }, open : function(ev, ui) { initEditConfirmInfo(); // CommnUtil.cleanInputValue("addcargoname,org,irradtype,irradtime,timeorg"); }, close : function(ev, ui) { //CommnUtil.cleanInputValue("cargoname,cargocount,cargoweight,showcountorginfos,funguscount,reqreagent,irradtypes,irradtime,timeorgs,irradflags,irradflag"); } }); //用于第一次初始化 $(function() { $('#receivetime').Zebra_DatePicker(); $("#editconfirmdetaildiv").dialog({ autoOpen : false,// 设置对话框打开的方式 不是自动打开 show : "bind", hide : "explode", modal : true, height : 500, width : 450, title: "编辑", buttons : { '保存' : function() { saveEditdetailInfo(); $(this).dialog("close"); }, "取消" : function() { $(this).dialog("close"); } }, open : function(ev, ui) { initEditConfirmInfo(); // CommnUtil.cleanInputValue("addcargoname,org,irradtype,irradtime,timeorg"); }, close : function(ev, ui) { //CommnUtil.cleanInputValue("cargoname,cargocount,cargoweight,showcountorginfos,funguscount,reqreagent,irradtypes,irradtime,timeorgs,irradflags,irradflag"); } }); $("#query").click("click", function() { search(0,"true"); }); $("#deleteconfirm").click("click", function() { deleteconfirm(); }); $("#pre").click("click", function() { dopre(); }); $("#next").click("click", function() { donext(); }); $("#editdetail").click("click", function() { alert("editdetail"); processeditdetail(); }); $("#checkalldetail").click("click", function() { allSelect(); }); $("#deletedetail").click("click", function() { deletedetail(); }); search(0,"true"); });
  • 打赏
  • 举报
回复
我猜应该是第二次访问这个页面的时候,有两种可能 1、页面没有加载到这段js, 但是你既然能访问alert()的两句,那证明没问题 2、这个ID获取的这个对象undefined了 看看这个
  • 打赏
  • 举报
回复
引用 6 楼 wzq6578702 的回复:
这个是个jquery对象,jquery写的看不懂,关于Id重复的,这个我能可以100%保证不会和jquery内部的冲突。 $('#editdetaildiv').dialog('open');这个是就是调用了上边定义的对话框,内部是jqueryUI的封装看不懂,时间也不允许啊。。。可咋整。。。。
汗... 这样吧,你既然用的是jquery的获取方式,那么也用jquery的初始化js的方式 改一下,改成这种方式: $(function{ $("#editdetaildiv").dialog({ autoOpen : false,// 设置对话框打开的方式 不是自动打开 show : "bind", hide : "explode", modal : true, height : 500, width : 450, buttons : { '保存' : function() { saveEditdetailInfo(); $(this).dialog("close"); }, "取消" : function() { $(this).dialog("close"); } }, open : function(ev, ui) { initEditConfirmInfo(); // CommnUtil.cleanInputValue("addcargoname,org,irradtype,irradtime,timeorg"); }, close : function(ev, ui) { //CommnUtil.cleanInputValue("cargoname,cargocount,cargoweight,showcountorginfos,funguscount,reqreagent,irradtypes,irradtime,timeorgs,irradflags,irradflag"); } }); 单击jsp中的一个按钮触发的弹框代码: function processeditdetail(){ if(CommnUtil.isHaveSelectOneCheckbox("confirmsDetailcheck")){ alert("processeditdetail"); $('#editdetaildiv').dialog('open'); }else{ alert("请选择而且只能选择一条详情记录!"); } } });
魔鬼_ 2015-08-19
  • 打赏
  • 举报
回复
引用 2 楼 sdl1314520 的回复:
火狐控制台debug,打断点逐步调试js,看哪里出了问题,$("#editdetaildiv").dialog({看这个方法进去了么
$("#editdetaildiv").dialog()方法肯定是走了,但是代码是jqueryUI的内部代码
魔鬼_ 2015-08-19
  • 打赏
  • 举报
回复
引用 4 楼 shijing266 的回复:
[quote=引用 3 楼 wzq6578702 的回复:] alert("processeditdetail");和alert("processeditdetailend");都执行了,所以我认为$('#editdetaildiv').dialog('open');这个也执行了,如果执行了,应该怎么定位这个问题。
$('#editdetaildiv') 这个是什么对象,你设个断点,看看到了这一步,这个对象是什么[/quote] 这个是个jquery对象,jquery写的看不懂,关于Id重复的,这个我能可以100%保证不会和jquery内部的冲突。 $('#editdetaildiv').dialog('open');这个是就是调用了上边定义的对话框,内部是jqueryUI的封装看不懂,时间也不允许啊。。。可咋整。。。。
  • 打赏
  • 举报
回复
还有获取对象建议用class的方式去获取,id的话,就怕重复
  • 打赏
  • 举报
回复
引用 3 楼 wzq6578702 的回复:
alert("processeditdetail");和alert("processeditdetailend");都执行了,所以我认为$('#editdetaildiv').dialog('open');这个也执行了,如果执行了,应该怎么定位这个问题。
$('#editdetaildiv') 这个是什么对象,你设个断点,看看到了这一步,这个对象是什么
魔鬼_ 2015-08-19
  • 打赏
  • 举报
回复
引用 1 楼 shijing266 的回复:
你页面审查元素,看看第二次调用的时候,有没有走到这一步$('#editdetaildiv').dialog('open')
我改了下代码: function processeditdetail(){ if(CommnUtil.isHaveSelectOneCheckbox("confirmsDetailcheck")){ alert("processeditdetail"); $('#editdetaildiv').dialog('open'); alert("processeditdetailend"); }else{ alert("请选择而且只能选择一条详情记录!"); } } shijing266 : alert("processeditdetail");和alert("processeditdetailend");都执行了,所以我认为$('#editdetaildiv').dialog('open');这个也执行了,如果执行了,应该怎么定位这个问题。
sdl1314520 2015-08-19
  • 打赏
  • 举报
回复
火狐控制台debug,打断点逐步调试js,看哪里出了问题,$("#editdetaildiv").dialog({看这个方法进去了么
  • 打赏
  • 举报
回复
你页面审查元素,看看第二次调用的时候,有没有走到这一步$('#editdetaildiv').dialog('open')
jquery文件,jquery1.8.24 /* NUGET: BEGIN LICENSE TEXT * * Microsoft grants you the right to use these script files for the sole * purpose of either: (i) interacting through your browser with the Microsoft * website or online service, subject to the applicable licensing or use * terms; or (ii) using the files as included with a Microsoft product subject * to that product's license terms. Microsoft reserves all other rights to the * files not expressly granted by Microsoft, whether by implication, estoppel * or otherwise. Insofar as a script file is dual licensed under GPL, * Microsoft neither took the code under GPL nor distributes it thereunder but * under the terms set out in this paragraph. All notices and licenses * below are for informational purposes only. * * jQuery UI; Copyright (c) 2012 Paul Bakaus; http://opensource.org/licenses/MIT * * Includes jQuery Easing v1.3; Copyright 2008 George McGinley Smith; http://opensource.org/licenses/BSD-3-Clause * * NUGET: END LICENSE TEXT */ /*! jQuery UI - v1.8.24 - 2012-09-28 * https://github.com/jquery/jquery-ui * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js, jquery.effects.blind.js, jquery.effects.bounce.js, jquery.effects.clip.js, jquery.effects.drop.js, jquery.effects.explode.js, jquery.effects.fade.js, jquery.effects.fold.js, jquery.effects.highlight.js, jquery.effects.pulsate.js, jquery.effects.scale.js, jquery.effects.shake.js, jquery.effects.slide.js, jquery.effects.transfer.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.tabs.js * Copyright (c) 2012 AUTHORS.txt; Licensed MIT */

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧