简体   繁体   English

触发检票口反馈面板时,如何自动向上滚动检票口面板?

[英]How to automatically scroll up a wicket panel when wicket feedbackpanel is trigged?

Im using a FeedbackPanel to show errormessage during validation controlls in a wicket form. 即时通讯使用FeedbackPanel以小门形式在验证控制期间显示错误消息。 When the message occurs it occur in the top of the form(page). 出现该消息时,它会出现在表单(页面)的顶部。 And my problem is that I might scrolled down when making a input and than I cant see the errormessage if I dont croll the form to the top of the page. 我的问题是,输入时我可能会向下滚动,如果不将表单滚动到页面顶部,那么我将看不到错误消息。 I would like to know how I can set the focus on the feedbackpanel so that everytime a errormessage is shown the form scrolls to the top automatically. 我想知道如何将焦点设置在反馈面板上,以便每次显示错误消息时,表单都会自动滚动到顶部。

I assume you use ajax-submit? 我假设您使用ajax提交?

Then you can add a javascript / jQuery to the AjaxRequestTarget . 然后,您可以将javascript / jQuery添加到AjaxRequestTarget For example this: 例如:

String myScript = " $('html, body').animate({scrollTop:$('#ELEMENT_ID').offset().top - 20}, 'slow');";
ajaxRequestTarget.appendJavascript(myScript);

Where you need to set the #ELEMENT_ID to your form. 您需要在表单上设置#ELEMENT_ID的位置。

Or alternatively, if you set a HTML ANCHOR (#) 或者,如果您设置了HTML ANCHOR (#)

function scrollTo(hash) {
    location.hash = "#" + hash;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM