Collection of small snippets for implementation of modular smart classes based on Javascript
Useful for AJAX buttons, delete element buttons, etc. that can break if the request is sent more than once.
$(".js-no-double-click").one("click", function() {
$(this).click(function () { return false; });
});
$('.js-no-submit-on-enter').find('input').keypress(function(e){
if (e.which == 13) {
e.preventDefault();
}
});
Useful for images/files uploads and stuff that take some time to send.
$('.js-loading').submit(function () {
$('#loading-modal').modal()
});
Very useful for files inputs if you want to show a different button than the usual one
$('.js-trigger-input').click(function() {
$('#' + $(this).data('input-id')).click();
});