【问题标题】:How can I prevent the default onRowClick action from being executed when clicking on an item in a table row?单击表格行中的项目时,如何防止执行默认的 onRowClick 操作?
【发布时间】:2018-10-10 13:52:50
【问题描述】:

在基于 Seam 2.2、jsf 1.2 和 Richfaces 3.3 的旧版应用程序中,我遇到了 Internet Explorer 问题:

我有一个带有可点击行的数据表。单击一行将打开该项目的详细视图。 最后一列包含一个垃圾桶图标。单击该图标时,将出现一个确认对话框。如果未确认,则不会发生其他任何事情。这在 Google Chrome 上运行良好。

它不适用于 Internet Explorer(在版本 11 上测试)。在这里,执行默认操作action="#{myAction.select(k)}"。 我尝试将event.preventDefault(); 添加到event.stopPropagation();,但这没有帮助。

我怎样才能让它在 Internet Explorer 上运行?

<rich:dataTable id="myDatatable" value="#{list.model}" var="k"
                headerClass="tableheader"
                onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                rowClasses="clickableRow">
    <a4j:support event="onRowClick" id="onRowClickEvent"
                 action="#{myAction.select(k)}"
                 reRender="myDatatable"/>

    <rich:column>
        <f:facet name="header">
            <a4j:commandLink action="#{list.changeOrder('k.name')}" 
                    value="Name #{list.orderColumn == 'k.name' ? (list.orderAscending ? '▲' : '▼') : ''}"
                    reRender="myDatatable" ajaxSingle="true" limitToList="true"/>
        </f:facet>
        <h:outputText value="#{k.name}"/>
    </rich:column>

    <rich:column style="text-align: center;">
        <f:facet name="header">
            <a4j:outputPanel layout="block">
                <h:outputText value="Delete"/>
            </a4j:outputPanel>
        </f:facet>

        <a4j:outputPanel onclick="event.preventDefault();event.stopPropagation();">
            <s:graphicImage value="/img/bin_closed.gif" style="cursor: pointer;">
                <a4j:support event="onclick"
                             action="#{myAction.delete(k)}"
                             ajaxSingle="true" limitToList="true"
                             onsubmit="if(!confirm('Are you sure?')) { return false; }" />
            </s:graphicImage>
        </a4j:outputPanel>
    </rich:column>

</rich:dataTable>

【问题讨论】:

    标签: java internet-explorer richfaces seam ajax4jsf


    【解决方案1】:

    我能够通过将event.preventDefault();event.stopPropagation(); 替换为Event.stop(event); 来解决问题,如该问题的答案所述: Stop JSF Event Chain, Answer by prageeth

    【讨论】:

      猜你喜欢
      • 2021-08-06
      • 1970-01-01
      • 2011-07-26
      • 1970-01-01
      • 1970-01-01
      • 2019-03-31
      • 1970-01-01
      • 2011-06-29
      • 2012-10-29
      相关资源
      最近更新 更多