Skip to content

Instantly share code, notes, and snippets.

@vojtech-dobes
Last active December 12, 2015 06:09
Show Gist options
  • Save vojtech-dobes/4727143 to your computer and use it in GitHub Desktop.
Save vojtech-dobes/4727143 to your computer and use it in GitHub Desktop.
$.nette.init(function (rh) {
$(this.linkSelector).off('click.nette', rh).on('click.nette', rh);
$(this.formSelector).off('submit.nette', rh).on('submit.nette', rh);
$(this.buttonSelector).off('click.nette', rh).on('click.nette', rh);
}, {
linkSelector: 'a.ajax',
formSelector: 'form.ajax',
buttonSelector: 'input.ajax[type="submit"], button.ajax[type="submit"], input.ajax[type="image"]'
});
$.nette.ext('disable-submit', {
prepare: function (settings) {
if (settings.nette.isForm) {
settings.nette.el.attr('data-ajax-pass', 'true');
}
},
complete: function () {
if (this.submit) {
this.submit.attr('disabled', false);
}
delete this.submit;
},
load: function () {
var that = this;
$('form').on('click', 'input[type="submit"]', function () {
that.submit = $(this);
});
$('form').on('submit', function () {
if (that.submit) {
that.submit.attr('disabled', true);
return false;
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment