javascript - Avoid onRowClick event when outputLink is clicked inside of RichFaces datatable -
how avoid call onrowclick on datatable on column has outputlink (target new window)?
<rich:datatable id="dt" value="#{bean.cars} var="_car"> <a:support event="onrowclick" action="#{action.navigatetocardetails(_car.id)}"/> <rich:column> <f:facet name="header">select</f:facet> <a:commandlink onclick="event.stop(event)" action="#{bean.toggleselectedcar(_car.id)}" rerender="dt" ajaxsingle="true" limittolist="true"> <h:graphicimage value="/img/icon_checkbox_#{bean.iscarselected(_car.id) ? 'active' : 'inactive'}.gif"/> </a:commandlink> </rich:column> <rich:column> <f:facet name="header">brand</f:facet> <h:outputlink value="#{_car.link}" target="_blank"> <h:outputtext value="#{_car.brand}"/> </h:outputlink> </rich:column> <rich:column> <f:facet name="header">year</f:facet> <h:outputtext value="#{_car.year}"/> </rich:column> <rich:column> <f:facet name="header">color</f:facet> <h:outputtext value="#{_car.color}"/> </rich:column> </rich:datatable>
so sample above, when click on row, navigate page detail of car.
and when clicked on select column's row, update selected car, , update checkbox icon accordingly, without navigate car detail page, because have onclick="event.stop(event)".
but when click on outputlink box, other opening new window , show manufacturer webpage, update original page car details. how prevent happening? (i tried adding onclick event stop select column, other stopping onrowclick event, block link manufacturer webpage)
basically event.stop(event)
following:
\\ stops event bubbling event chain event.stoppropagation(); \\ prevents default action browser makes on event event.preventdefault();
in case want prevent bubbling, way go:
onclick="event.stoppropagation()"
Comments
Post a Comment