You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kamil Hark <ka...@gmail.com> on 2008/12/11 13:03:43 UTC
go top after ajax
Hi, I use AjaxSubmitLink as a submit link for big and long form. In onError
method I add to AjaxRequestTarget whole form and some error messages. I'd
like to go top after ajax but I don't know how.
I tried to do two folowings but it does not work.
1.
protected void onError(AjaxRequestTarget target, Form form) {
target.appendJavascript("window.document.body.scrollTop = 0;
window.document.documentElement.scrollTop = 0");
target.addComponent(longBigForm);
}
2. in AjaxCallDecorator
public CharSequence decorateOnSuccessScript(CharSequence script) {
return "window.document.body.scrollTop = 0;
window.document.documentElement.scrollTop = 0; "
+ decoratePostEventScript(super.decorateOnSuccessScript(script));
}
in both situations I see that browser shows top but after that immediately
back down
have you any sugestions?
Kamil
--
View this message in context: http://www.nabble.com/go-top-after-ajax-tp20954146p20954146.html
Sent from the Wicket - User 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: go top after ajax
Posted by Kamil Hark <ka...@gmail.com>.
target.focusComponent(...) + "window.document.body.scrollTop = 0;
window.document.documentElement.scrollTop = 0; " work just as I need.
Thanks.
--
View this message in context: http://www.nabble.com/go-top-after-ajax-tp20954146p20954690.html
Sent from the Wicket - User 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: go top after ajax
Posted by Martijn Dashorst <ma...@gmail.com>.
probably the browser focuses on the submit button, causing it to
scroll down again. target.focusComponent(...) should do the trick.
Martijn
On Thu, Dec 11, 2008 at 1:03 PM, Kamil Hark <ka...@gmail.com> wrote:
>
> Hi, I use AjaxSubmitLink as a submit link for big and long form. In onError
> method I add to AjaxRequestTarget whole form and some error messages. I'd
> like to go top after ajax but I don't know how.
> I tried to do two folowings but it does not work.
>
> 1.
> protected void onError(AjaxRequestTarget target, Form form) {
> target.appendJavascript("window.document.body.scrollTop = 0;
> window.document.documentElement.scrollTop = 0");
> target.addComponent(longBigForm);
> }
>
> 2. in AjaxCallDecorator
>
> public CharSequence decorateOnSuccessScript(CharSequence script) {
> return "window.document.body.scrollTop = 0;
> window.document.documentElement.scrollTop = 0; "
> + decoratePostEventScript(super.decorateOnSuccessScript(script));
> }
>
> in both situations I see that browser shows top but after that immediately
> back down
>
> have you any sugestions?
> Kamil
> --
> View this message in context: http://www.nabble.com/go-top-after-ajax-tp20954146p20954146.html
> Sent from the Wicket - User 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
>
>
--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org