News for hackers. Stuff that matters.
Re:Double-clicking on the Web by nodesocket on Saturday April 18, 2015 @04:56AM (#9398777)
Is it me, or why is a setTimeout needed in this example?

$(document).ready(function(){ $("form").submit(function(){ setTimeout(function() { $('input').attr('disabled', 'disabled'); $('a').attr('disabled', 'disabled'); }, 50); }) });

Re:Double-clicking on the Web by nailer on Saturday April 18, 2015 @06:17AM (#9398895)
50 should be a constant called NEXT_TICK with a value of 0. This makes it run on the next event loop, ie, default event submit form, next tick afterwards the form is disabled
Re:Double-clicking on the Web by xrstf on Saturday April 18, 2015 @06:46AM (#9398958)
You are looking for setImmediate[1].

EDIT: Oh, never knew that this method was a Node-ism only.

[1] https://developer.mozilla.org/en-US/docs/Web/API/Window/setI...

Re:Double-clicking on the Web by nailer on Sunday April 19, 2015 @03:41PM (#9404535)
Actually it's common enough that

    var setNextTick = function(nextTickFunction){window.setTimeout(nextTickFunction), 0}) 
...sounds like a damn good idea.

Hate the name 'setImmediate' though, immediate implies the current tick and people would wonder why you're using it.

Re:Double-clicking on the Web by seszett on Saturday April 18, 2015 @06:06AM (#9398878)
Some browsers will not submit the form if you disable the submit input inside the submit event.
Re:Double-clicking on the Web by kacperp on Saturday April 18, 2015 @05:14AM (#9398798)
Was asking myself the same thing. This would make sense if your submit button will actually cause an ajax request that you might want to repeat. But actually submitting the form will cause a page reload either way, or not?