javascript - BlockUI scrolls to top -
i using jquery blockui plugin:
function block(msg) { $.blockui({ message: msg, css: { border: 'none', padding: '15px', backgroundcolor: '#000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .8, color: '#fff' } }); } function unblock() { $.unblockui(); }
the problem facing is, call it, scrolls page top. not good.
here generated html:
is there modify not touch pageoffset / scrolling? there preserve or anything?
thanks
called here:
function callbump(realid) { block('bumping...'); $.ajax({ type: "post", url: "calendarservices.aspx/bump", data: 'id=' + realid, success: function (data) { $('#calendar').fullcalendar('refetchevents'); unblock(); } , error: function () { unblock(); } }); }
i'm guessing jump top caused having this:
<a href="#" id="do_bump">bump!</a>
whatever click event have bound link executing continues attempt navigate "#" causing jump.
it can fixed capturing event parameter (add e
click event handler) , calling preventdefault()
on it. prevents default link click behavior occurring, navigate href
attribute value.
given comments, have this:
$(btnbump).off('click'); $(btnbump).on('click', function () { callbump(event.realid); });
where event
coming from? window.event
? assuming jquery might mangle event, try (you have add event parameter e
):
$(btnbump).on('click', function(e) { callbump(event.realid); e.preventdefault(); });