简体   繁体   English

单击表行中的项目时,如何防止执行默认的onRowClick操作?

[英]How can I prevent the default onRowClick action from being executed when clicking on an item in a table row?

In a legacy application based on Seam 2.2, jsf 1.2, and Richfaces 3.3, I am having a problem with Internet Explorer: 在基于Seam 2.2,jsf 1.2和Richfaces 3.3的旧版应用程序中,Internet Explorer出现问题:

I have a datatable with clickable rows. 我有一个带有可点击行的数据表。 Clicking on a row will open the detailed view of the item. 单击一行将打开该项目的详细视图。 The last column contains a trashbin icon. 最后一列包含垃圾桶图标。 When clicking the icon a confirmation dialog appears. 单击图标时,将显示一个确认对话框。 When not confirmed, nothing else should happen. 如果未确认,则什么也不会发生。 This works fine on Google Chrome. 在Google Chrome上运行良好。

It doesn't work with Internet Explorer (testing on Version 11). 它不适用于Internet Explorer(在版本11上测试)。 Here, the default action action="#{myAction.select(k)}" is executed. 在此,执行默认操作action="#{myAction.select(k)}" I tried adding event.preventDefault(); 我尝试添加event.preventDefault(); to the event.stopPropagation(); event.stopPropagation(); but that did not help. 但这没有帮助。

How can I get this to work on Internet Explorer? 如何在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>

I was able to solve the problem by replacing event.preventDefault();event.stopPropagation(); 我可以通过替换event.preventDefault();event.stopPropagation();解决问题event.preventDefault();event.stopPropagation(); with Event.stop(event); Event.stop(event); as described in the answer to this question: Stop JSF Event Chain, Answer by prageeth 如对此问题的答案所述: 停止JSF事件链,由prageeth回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当Optional不为空时,如何防止传递给Optional的orElse的函数被执行? - How to prevent the function passed to Optional's orElse from being executed when the Optional is not empty? 如何防止if语句在首次检查其条件时仅执行一次? - How to prevent if-statement from being executed only once when its condition is first checked? 按下右 ALT 键 (ALT Gr) 时,如何防止发送 CTRL KeyEvent? - How can I prevent the CTRL KeyEvent from being dispatched when pressing the right ALT key (ALT Gr)? Java:将Canvas添加到JFrame时,如何防止调整Canvas的大小? - Java: How can I prevent Canvas from being resized when it is added to a JFrame? 用户刷新页面时,如何防止购物车商品增加? - How can I prevent the shopping cart item from incrementing when the user refresh the page? 我如何防止所有单元格变色? - how i can i prevent all the cells from being colored? 使用 DecimalFormat 时如何防止小数四舍五入? - How can I prevent decimals being rounded when using DecimalFormat? 如何防止JavaFX中的窗口太小? - How can I prevent a window from being too small in JavaFX? 退出应用程序时如何防止服务被破坏 - How to prevent the service from being destroyed when I exit the app 如何通过单击带有 struts2 操作的按钮来获取表格元素的 id - How can I get the id of the table element by clicking on the button with struts2 action
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM