我是Rich Faces的新手,我們使用的是Richfaces 4.0。我們的項目中有一個彈出式需求,我們使用rich:popupPanel。
在彈出的對話框中,我們有一個5到10個輸入文本框的表單。Tab索引不工作richfaces彈出面板
我們正面臨以下問題: 選項卡不能正常工作以進入下一個文本框。
我們使用tabindex屬性,但它不適用於豐富的表情。
任何人都可以幫助我嗎?
在此先感謝。
我是Rich Faces的新手,我們使用的是Richfaces 4.0。我們的項目中有一個彈出式需求,我們使用rich:popupPanel。
在彈出的對話框中,我們有一個5到10個輸入文本框的表單。Tab索引不工作richfaces彈出面板
我們正面臨以下問題: 選項卡不能正常工作以進入下一個文本框。
我們使用tabindex屬性,但它不適用於豐富的表情。
任何人都可以幫助我嗎?
在此先感謝。
下面是一個簡單彈出面板與標籤功能在RichFaces的4啓用:
<script type="text/javascript">
jQuery('input').live("keypress", function(e) {
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
/* ENTER PRESSED*/
if (key == 9) { // 9 for TAB
/* FOCUS ELEMENT */
var inputs = jQuery(this).parents("form").eq(0).find(":input");
var idx = inputs.index(this);
var move = (e.shiftKey) ? (-1) : (1); // for Shift+TAB
if (idx == inputs.length - 1) {
inputs[0].select()
} else {
inputs[idx + move].focus(); // handles submit buttons
inputs[idx + move].select();
}
return false;
}
});
</script>
<rich:jQuery query="focus().select()" selector="#thegrid :input:visible:enabled:first" name="focusInput"/>
<rich:popupPanel id="samplepopup" modal="true" resizeable="true" height="220" width="400"
onmaskclick="#{rich:component('samplepopup')}.hide()"
onshow="focusInput();">
<f:facet name="header">
<h:outputText value="sample"/>
</f:facet>
<h:form>
<h:panelGrid id="thegrid" columns="2" style="direction: rtl;">
<h:outputText value="Current Pass"/>
<h:inputSecret id="pass1" value="#{userBean.pass}"/>
<h:outputText value="New Pass"/>
<h:inputSecret id="pass2" value="#{userBean.newPass}"/>
<h:outputText value="New Pass Confirm"/>
<h:inputSecret id="pass3"/>
</h:panelGrid>
</h:form>
</rich:popupPanel>
<a4j:commandButton value="show sample" onclick="#{rich:component('samplepopup')}.show()"/>
一個通用的解決方法可能是重寫負責功能:
RichFaces.ui.PopupPanel.prototype.processTabindexes = function (input) {
if (!this.firstOutside) {
this.firstOutside = input;
}
if (!input.prevTabIndex) {
input.prevTabIndex = input.tabIndex;
// input.tabIndex = -1; // This line was marked out
}
if (!input.prevAccessKey) {
input.prevAccessKey = input.accessKey;
input.accessKey = "";
}
};
這工作,但人卻是它醜陋。它會導致選項卡完全打破自然html tabindex自然工作的窗體的其他部分。 – Eric