You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by bjolletz <da...@pagero.com> on 2012/05/05 15:15:31 UTC

Error with link in DataTable together with AjaxEventBehavior("onclick")

Hi,

I have a DataTable. In this DataTable I want to be able to click on the rows
in the table to make some stuff happen (by Ajax), for example highlighting
the current row. To implement this I am overriding the newRow method in
DataTable and adding an AjaxEventBehavior("onclick") to each row item.

This works well, but when I add a Link to another page in one of the
columns, I get a problem. When clicking the link I still trigger an onclick
ajax event for clicking the row. But since the link takes me to another
page, this ajax request will fail beacuse the page it belongs to is no
longer available.

Is there a way to prevent the onclick event from happening when I click on
my link? Or is there a better way of doing this?

Thanks!
Daniel

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-with-link-in-DataTable-together-with-AjaxEventBehavior-onclick-tp4611096.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Error with link in DataTable together with AjaxEventBehavior("onclick")

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

This is how the event propagation/bubbling works in the browsers.
You need to suppress the bubbling of the JavaScript event.
See http://www.quirksmode.org/js/events_order.html for more info.
You can use IAjaxCallDecorator to stop the event after clicking on the
ajax link.

On Sat, May 5, 2012 at 4:15 PM, bjolletz <da...@pagero.com> wrote:
> Hi,
>
> I have a DataTable. In this DataTable I want to be able to click on the rows
> in the table to make some stuff happen (by Ajax), for example highlighting
> the current row. To implement this I am overriding the newRow method in
> DataTable and adding an AjaxEventBehavior("onclick") to each row item.
>
> This works well, but when I add a Link to another page in one of the
> columns, I get a problem. When clicking the link I still trigger an onclick
> ajax event for clicking the row. But since the link takes me to another
> page, this ajax request will fail beacuse the page it belongs to is no
> longer available.
>
> Is there a way to prevent the onclick event from happening when I click on
> my link? Or is there a better way of doing this?
>
> Thanks!
> Daniel
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-with-link-in-DataTable-together-with-AjaxEventBehavior-onclick-tp4611096.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org