【发布时间】:2012-01-31 11:06:39
【问题描述】:
说实话,我对JavaScript不够专业,但我感觉我的问题很奇怪o.O
事实上,我有一个包含模板列表的SelectBox。如果我选择一个,onchange 事件将通过 Ajax 调用得到很好的处理,并且表单显示为选中状态。
好的
现在,如果偶然一个包含SelectBox 的表单并且它还包含onchange,则该事件将被忽略并且不会发生任何事情。
正常
<div class="UIDocumentFormController" id="UIDocumentFormController">
<div style="display: block;">
<div class="UIFormWithoutAction UISelectDocumentForm">
<form class="UIForm" id="UISelectDocumentForm" action="/portal/private/acme/siteExplorer?portal:componentId=4e6208eb-b0d7-468c-bd01-6f63a38118fc&portal:type=action&uicomponent=UISelectDocumentForm" onsubmit="Change" method="post">
<div><input type="hidden" name="formOp" value=""></div>
<div class="HorizontalLayout">
<table class="UIFormGrid">
<tbody>
<tr>
<td class="FieldLabel">Sélectionner un formulaire</td>
<td class="FieldComponent">
<select class="selectbox" name="selectTemplate" onchange="javascript:eXo.webui.UIForm.submitEvent('4e6208eb-b0d7-468c-bd01-6f63a38118fc#UISelectDocumentForm','Change','&objectId=selectTemplate')">
<option value="exo:article">Article</option>
<option value="exo:cssFile">CSS File</option>
<option value="exo:event">Event</option>
<option value="nt:file">File</option>
<option selected="selected" value="exo:articletest">teeest</option>
</select>
</td>
</tr>
</tbody></table>
</div>
</form>
</div>
</div>
<div style="display: block;">
<div class="UIForm FormLayout">
<form class="UIForm" id="UIDocumentForm" action="/portal/private/acme/siteExplorer?portal:componentId=4e6208eb-b0d7-468c-bd01-6f63a38118fc&portal:type=action&uicomponent=UIDocumentForm" method="post">
<div><input type="hidden" name="formOp" value=""></div>
<div class="HorizontalLayout">
<table class="UIFormGrid">
<tbody>
<tr>
<td class="FieldLabel">Nom</td>
<td class="FieldComponent"><input name="name" type="text" id="name"> * </td>
</tr>
<tr>
<td class="FieldLabel">Select</td>
<td class="FieldComponent">
<select class="selectbox" name="introducerTitle" onchange="javascript:eXo.webui.UIForm.submitEvent('4e6208eb-b0d7-468c-bd01-6f63a38118fc#UIDocumentForm','Change','&objectId=introducerTitle')">
<option value="aaa">aaa</option>
<option value="bbb">bbb</option>
</select>
</td>
</tr>
</tbody>
</table>
<div class="UIAction">
<table class="ActionContainer">
<tr>
<td>
<div onclick="javascript:eXo.webui.UIForm.submitForm('4e6208eb-b0d7-468c-bd01-6f63a38118fc#UIDocumentForm','Save',true)" class="ActionButton LightBlueStyle">
<div class="ButtonLeft">
<div class="ButtonRight">
<div class="ButtonMiddle"><a href="javascript:void(0);">Sauver comme brouillon</a></div>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</form>
</div>
</div>
</div>
奇怪且不合逻辑的事情:
如果我检查SelectBox(使用FireBug 或任何类似工具),并在调用的函数中进行任何更改(删除一个字母并重写),SelectBox 就会起作用并且onchange 调用的事件会运行。
注意:Ajax 调用使用 Java 代码创建表单,我认为这是渲染的问题。
【问题讨论】:
-
能否请您提供一段代码来演示您的问题。
标签: javascript rendering onchange