Using jquery.form.js ajaxSubmit() scrolls to the top of page after it succeeds. Is this normal?
Hi I have managed to get my form to submit without reloading, using this plugin: http://jquery.malsup.com/form/ And also with the regular .post() method however the browser always scrolls to the top. Is this normal?
$(document).ready(function()
{
// Temporary upload demo
if ($("#breadcrumbs:contains('AdrianTest')").length)
{
$('form.ltpo-form').ajaxForm();
$('form.ltpo-for开发者_开发问答m').submit(function(event) {
event.preventDefault();
return false;
});
$('form.ltpo-form').submit(function() {
// submit the form
var options = {
data: { p_action: 'Save' },
success: function() {
alert('Success');
}
};
$(this).ajaxSubmit(options);
// return false to prevent normal browser submit and page navigation
event.preventDefault();
return false;
});
}
...
i had problems n was because i was using the ajaxSubmit and ajaxForm inside a wrap function like your
$('form.ltpo-form').submit(function() {
the issue is being caused by another script: jquery.single-ddm.pack.js
(function(A){A.fn.singleDropMenu=function(C){var F;var E;var D=A.extend({timer:500,parentMO:null,childMO:null},C||{});this.each(function(){A("li",this).mouseover(function(){B();A("a",this).addClass(D.parentMO).siblings("ul").show()}).mouseout(function(){E=this;F=setTimeout(function(){B()},D.timer)});A("li ul li",this).mouseover(function(){if(D.childMO){A("a",this).addClass(D.childMO)}}).mouseout(function(){if(D.childMO){A("a",this).removeClass(D.childMO)}})});A(document).click(function(){B()});var B=function(){if(E&&F){A("a",E).removeClass(D.parentMO).siblings("ul").hide();clearTimeout(F);E=""}}}})(jQuery);
I am still interested in knowing how to stop this script from scrolling the page on ajaxSubmit...
精彩评论