Last active
December 12, 2015 06:09
-
-
Save vojtech-dobes/4727143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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"]' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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