0

我在使用 Spring.AjaxEventDecoration 和 dijit.form.Select 时遇到问题,如果用户以某种方式从选择框中选择性别类型,我在 bean 中获取的 elementID 是 Spring MVC?下面是我的表格:

<form:select path="sex">
<form:option value="MALE" label="MALE" />
<form:option value="FEMALE" label="FEMALE" />
</form:select> 
<script type="text/javascript">
  Spring.addDecoration(new Spring.ElementDecoration({
  elementId : "sex",
  widgetType : "dijit.form.Select",
  widgetAttrs : {
  promptMessage : "Enter Sex",
  required : true }}));

  Spring.addDecoration(new Spring.AjaxEventDecoration({
  elementId: "sex",
  event: "onChange",
  formId:"customer",
  params: {fragments:"body", _eventId: "loadSchools"}}));
</script> 
4

1 回答 1

0

我解决了这个问题。我删除了Spring.AjaxEventDecoration调用并将Spring.ElementDecoration更改为以下内容:

 <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "sex",
                                widgetType : "dijit.form.Select",
                                widgetAttrs : {
                                promptMessage : "Enter Sex",
                                required : true, 
                                onChange : function() {
                                    Spring.remoting.submitForm(
                                        'submit', 
                                        'customer', 
                                        {_eventId: 'sexchange', fragments:'contents'}
                                     ); 
                                     return false;
                                } }}));


                        </script>

我不是 100% 清楚为什么 Ajax 调用不起作用,但我的项目现在正在使用此代码!

于 2012-10-12T16:38:48.963 回答