I have to submit form by ajax, and I wanеd set delay before submit my entering data but only when I put in input field. When I change in select field, form submit at once
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
var timerid; $(document).on('input change',".mode_cost_update", function(e) { form_id = "#edit_model_cost_"+$(this).data('id'); type=$(this).get(0).tagName; // For select submit at once if (type=='SELECT') { $(form_id).submit(); } // For other submit after 1s else { clearTimeout(timerid); timerid = setTimeout(function() { $(form_id).submit(); }, 1000); } }); |