forked from GNUsocial/gnu-social
Bind submit to a form by SN.U.FormXHR() only once.
This commit is contained in:
parent
42da45d3bc
commit
7164a53f85
55
js/util.js
55
js/util.js
@ -131,34 +131,37 @@ var SN = { // StatusNet
|
||||
},
|
||||
|
||||
FormXHR: function(f) {
|
||||
f.bind('submit', function(e) {
|
||||
form_id = $(this)[0].id;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'xml',
|
||||
url: $(this)[0].action,
|
||||
data: $(this).serialize() + '&ajax=1',
|
||||
beforeSend: function(xhr) {
|
||||
$('#'+form_id).addClass(SN.C.S.Processing);
|
||||
$('#'+form_id+' .submit').addClass(SN.C.S.Disabled);
|
||||
$('#'+form_id+' .submit').attr(SN.C.S.Disabled, SN.C.S.Disabled);
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
alert(errorThrown || textStatus);
|
||||
},
|
||||
success: function(data, textStatus) {
|
||||
if (typeof($('form', data)[0]) != 'undefined') {
|
||||
form_new = document._importNode($('form', data)[0], true);
|
||||
$('#'+form_id).replaceWith(form_new);
|
||||
$('#'+form_new.id).each(function() { SN.U.FormXHR($(this)); });
|
||||
if (jQuery.data(f[0], "ElementData") === undefined) {
|
||||
jQuery.data(f[0], "ElementData", {Bind:'submit'});
|
||||
f.bind('submit', function(e) {
|
||||
form_id = $(this)[0].id;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'xml',
|
||||
url: $(this)[0].action,
|
||||
data: $(this).serialize() + '&ajax=1',
|
||||
beforeSend: function(xhr) {
|
||||
$('#'+form_id).addClass(SN.C.S.Processing);
|
||||
$('#'+form_id+' .submit').addClass(SN.C.S.Disabled);
|
||||
$('#'+form_id+' .submit').attr(SN.C.S.Disabled, SN.C.S.Disabled);
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
alert(errorThrown || textStatus);
|
||||
},
|
||||
success: function(data, textStatus) {
|
||||
if (typeof($('form', data)[0]) != 'undefined') {
|
||||
form_new = document._importNode($('form', data)[0], true);
|
||||
$('#'+form_id).replaceWith(form_new);
|
||||
$('#'+form_new.id).each(function() { SN.U.FormXHR($(this)); });
|
||||
}
|
||||
else {
|
||||
$('#'+form_id).replaceWith(document._importNode($('p', data)[0], true));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#'+form_id).replaceWith(document._importNode($('p', data)[0], true));
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
FormNoticeXHR: function(form) {
|
||||
|
Loading…
Reference in New Issue
Block a user