【发布时间】:2011-06-20 18:36:18
【问题描述】:
我已尝试查找可在a4j:support 事件属性中使用的所有可能事件的列表。我找不到任何列出它们的参考资料,也许有人可以提供链接?
我知道onclick、onchange 等显而易见的问题。
我问这个的原因是我目前有一个输入文本字段。它通过a4j:support 标签附加了onkeyup 事件。它应该在事件触发时启用一个文本框。
当用户右键单击鼠标并将内容粘贴到字段中时,该事件不会触发。
我可以使用其他事件来确保管理此案例吗?
<h:inputText id="someName" value="#{myBean.example.exampleName}" maxlength="25" style="width:280px">
<a4j:support event="onchange" reRender="exampleTab"
action="#{myBean.activateTabPanel}" ajaxSingle="true"
ignoreDupResponses="true" />
</h:inputText>
<rich:tabPanel id="exampleTab" switchType="server"
style="width:100%;height:448px;" styleClass="top_tab"
inactiveTabClass="inactive_tab" activeTabClass="active_tab"
selectedTab="#{myBean.exampleTabState.selectedTab}">
<!-- Various stuff in here --->
</rich>
## ************ 更新 ***********##
我实际上最终选择了一个 jQuery 解决方案。干净多了。为任何感兴趣的人附上代码。
jQuery(document).ready(function() {
// Call contructor
var common = new Site.Common();
});
// Constructor
Site.Common = function() {
// Only attach event listener if the element exists on page
if ( jQuery('input[id$="suggest"]') ) {
jQuery('input[id$="suggest"]').bind('paste', Site.Common.handleMousePaste.bind(this));
}
};
// Trigger the keyup event when user uses mouse to paste content info a field('element')
Site.Common.handleMousePaste = function(event) {
// Need to split the id (JSF adds the form name in front of the input field!)
var idParts = event.target.id.split(':');
// Reformat the id we will pass to jQuery (It does not understand formName:fieldName, need to escape the ':')
if (idParts.length >= 2) {
var formattedID = "#" + idParts[0] + "\\:" + idParts[1];
}
else {
var formattedID = "#" + event.target.id;
}
// Need to put a tiny delay in so the element has time to get the pasted in content.
setTimeout(function() { jQuery(formattedID).keyup(); }, 10);
};
谢谢
【问题讨论】:
标签: javascript jsf dom-events richfaces