onChange does not work for dateTimePicker in struts2

巧了我就是萌 提交于 2019-12-12 01:59:33

问题


I have the following piece of code :

<sx:datetimepicker name="dateOfBirth" id="dateOfBirth"
displayWeeks="5" displayFormat="dd/MM/yyyy" onchange="test()"/>

But for this the onchange event does not work althought i have a simple javascript function like this :

<script>
function test(){
    alert('hi-----');
}
</script>

Note: I read somewhere that it is a bug in struts that the onChange event doesnt work for dateTimePicker. However I am not sure about it. Is there any workaround discovered for it?


回答1:


Dojo tags are deprecated. Use jQuery tags. You can find more about struts2-jquery-plugin. You should use datepiker tag.

<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<head>
  <link href="<s:url value="/css/template_styles.css"/>" type="text/css" rel="stylesheet">
  <sj:head jqueryui="true" />
  <title></title>
</head>

<script type="text/javascript">
$.subscribe('changeTopic', function(event,data) {
    alert('Date : '+event.originalEvent.dateText);
});
</script>  
<sj:datepicker name="dateOfBirth" id="dateOfBirth" label="DOB" displayFormat="dd/MM/yy" onChangeTopics="changeTopic"/>


来源:https://stackoverflow.com/questions/25159250/onchange-does-not-work-for-datetimepicker-in-struts2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!