1

I'm having problems with datepickers inside a dialog modal. After each date selection, the page scrolls to the top of the dialog which is very annoying.

Using jQuery 1.9 & jQuery-ui 1.10 and tried both minified & normal versions.

Tried the following

(F?" ui-priority-secondary":"")+'" href="#">'+q.getDate()+"</a>")+"</td>"

to

(F?" ui-priority-secondary":"")+'" href="javascript:;">'+q.getDate()+"</a>")+"</td>"

and

href="javascript:return false;"

But none seem to work.

fes
  • 2,465
  • 11
  • 40
  • 56
  • Simply try `##` instead of `#` – artm Nov 09 '14 at 10:32
  • no luck - still scrolls to the top – fes Nov 09 '14 at 10:41
  • Could you post some code, maybe in a jsFiddle? Are you sure it's the datepicker causing the problem, not the opening of the modal dialog? – Dave Salomon Nov 09 '14 at 10:48
  • http://bugs.jqueryui.com/ticket/5498 - just tried to get the latest 1.10.4 but now it shows the date after selection, pauses for 1 second and then scrolls to the top. – fes Nov 09 '14 at 11:10
  • i downgraded to ui 1.9.2 and seems to not have the issue - ill stick with that. – fes Nov 09 '14 at 11:18

1 Answers1

0

you can use javascript:void(0); or read about event.preventDefault() if you are using jquery its the easy way to do it, more information https://developer.mozilla.org/en/docs/Web/API/event.preventDefault

if you are using a # without the prevent.default always its gonna take you to the top of the browser javascript:; its gonna create and error in javascript script.

read also this event.preventDefault() vs. return false and read the comments about return false;

Community
  • 1
  • 1
ncubica
  • 8,169
  • 9
  • 54
  • 72
  • sorry but cant help without you entire code what its `(F?` doing? and yes thats the answer your problem should be in other place... – ncubica Nov 09 '14 at 10:42