You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christian Mader <ch...@univie.ac.at> on 2011/06/06 15:38:12 UTC

Expanding tree and scrolling to item

Hello,

I have an ajax link and a tree located at the same page. When I click on 
the link I want the tree to expose a specific item and scroll the item 
into view.
Exposing the item works well using getTreeState().expandNode(childNode); 
and after adding the tree component to the AjaxRequestTarget it displays 
properly.
I append javascript code to the AjaxRequestTarget to scroll to the 
expanded item, but this only works if the tree is already completely 
expanded. Otherwise, the scroll location is not correct.

I assume this is because the scroll js command is issued before the tree 
is completely expanded. Is there any possiblity to wait for the tree to 
be displayed and then issue the scroll command? Would overriding 
onAfterRender() help on this issue? How can I get an AjaxRequestTarget 
in onAfterRender()?

I would be happy for any reply that points me into the right direction 
to solve this problem.

Best,
Christian

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


Re: Expanding tree and scrolling to item

Posted by Pedro Santos <pe...@gmail.com>.
Hi Christian, the appended JavaScript with
AjaxReuqestTarget#appendJavascript already will be called after tree
DOM update. Try to postpone your scroll JavaScript wrapping it in an
function to setTimeout method.

On Mon, Jun 6, 2011 at 10:38 AM, Christian Mader
<ch...@univie.ac.at> wrote:
> Hello,
>
> I have an ajax link and a tree located at the same page. When I click on the
> link I want the tree to expose a specific item and scroll the item into
> view.
> Exposing the item works well using getTreeState().expandNode(childNode); and
> after adding the tree component to the AjaxRequestTarget it displays
> properly.
> I append javascript code to the AjaxRequestTarget to scroll to the expanded
> item, but this only works if the tree is already completely expanded.
> Otherwise, the scroll location is not correct.
>
> I assume this is because the scroll js command is issued before the tree is
> completely expanded. Is there any possiblity to wait for the tree to be
> displayed and then issue the scroll command? Would overriding
> onAfterRender() help on this issue? How can I get an AjaxRequestTarget in
> onAfterRender()?
>
> I would be happy for any reply that points me into the right direction to
> solve this problem.
>
> Best,
> Christian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Pedro Henrique Oliveira dos Santos

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