开发者

How to stop dojo from scrolling to required input

I have a long webpage with a form at the bottom. The form has several inputs and one of them is required="true". After the parser parses开发者_运维问答 all the inputs and dojoifies them, it scrolls down to that required field - which of cours is not what I want the visitors to see first since the important things are at the top of the page. This scrolling behaviour might be smart in some cases - but in my case it totally sucks.

How do I tell dojo to stop scrolling to the required text input?

Thanks to all the dojo gurus out there!


The base widget dijit.form._FormWidget has scrollOnFocus property that is inherited by descendant widgets.
Set it to false. It helped me to prevent scrolling to buttons.


That won't work because the dijit.Form contains the logic that focuses the first invalid field.
The quickest solution I can think of is adding a patch that would override validate method of dijit.form._FormMixin. You'll need to require the patch on those pages where you want new behavior.

dojo.provide("your.namespace.FormPatch");
dojo.extend(dijit.form._FormMixin, {
    validate: function() { /* your implementation here */ }
});

You can also define a new widget that would inherit from dijit.Form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜