我有一个带取消按钮的窗口,默认关闭[x].当用户单击取消按钮时,它应检查特定标志并关闭窗口并更新db.我正在使用me.close(this); 关闭取消按钮的窗口.当用户单击[x]时,它应检查相同的标志并更新db,然后关闭窗口.为了检查那个标志条件,我添加了一个监听器这个监听器工作正常.但是在添加监听器后,单击取消按钮,将关闭事件两次.所以db更新发生了两次.有人可以建议我如何处理窗口的[x]关闭事件
Ext.define('MyApp.view.updateForm', {
extend: 'Ext.window.Window',
height: 600,
width: 800,
layout: {
type: 'absolute'
},
title: 'Update Window',
modal: true,
initComponent: function() {
Ext.applyIf(me, {
items: [
{
xtype: 'button',
id:'btnCancel',
handler : function(){
if(flag == true){
//add to db
me.close(this);
}
}
}]
});
me.callParent(arguments);
},
listeners:{
close:function(){
if(flag == true){
alert("close window");
//add to db
}
}
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个有很多可见和隐藏的单选按钮的表单.我只需要获得可见的单选按钮并进行一些操作.我正在尝试下面的代码.但它不起作用.有人可以帮助我.
$('#submitbutton').click(function () {
var returnVal = true;
$.each($('.input-container[data-validation=required]'), function (idx, group) {
$(group).next('ul.innererrormessages').remove();
var unchecked = $(group).find(':radio').filter(':visible');
if (!unchecked.is(':checked')) {
var title = unchecked.attr('title');
$(group).after('<ul class="innererrormessages"><li>' + title + '</li></ul>');
returnVal = false;
}
});
});
Run Code Online (Sandbox Code Playgroud)
一组有4-5个单选按钮.我需要检查组中的任何单选按钮是否已选中.所以我不确定上面的代码是否真的检查是否检查了组中的任何一个单选按钮.因为即使在检查了所有单选按钮之后,它也将returnVal设置为false.如果我尝试提醒returnVal,首先它给出了true,然后它给出了所有的错误.
我试图清理一个用jsp servlet和javascript,jquery编写的应用程序.目前在jsp中,有很多javascripts写的.我试图将所有这些javascripts移动到一个单独的js文件.在jsp中,它通过javascript获取contextPath,然后使用此contextPath做一些逻辑.是否可以在javascript中获取上下文路径?它也在jsp中使用这样的代码.如何将此代码移动到js文件?
HTML
<input type="button" id="cntButton" value="CONTINUE" onclick="javascript: callTest('<%=request.getContextPath()%>/test1/test2/test3.do');"/>
function callTest(pageURL){
}
Run Code Online (Sandbox Code Playgroud)
如果我将函数callTest(pageURL)移动到javascript文件,我如何从jsp传递contextPath?
更新2
在jsp中,
<%
String firstName= "";
if (sampleBean.getName() != null) {
firstName = sampleBean.getName();
}
%>
<script type="text/javascript">
window.onload=loadVal;
function loadVal() {
document.getElementById('business_name').value = "<%=firstName%>";
}
</script>
Run Code Online (Sandbox Code Playgroud)
我需要将此loadVal()移动到另一个js文件.那么如何传递从bean中获取的"<%= firstName%>"?