[英]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.