Modal blocking dialog in Javascript <p>I'm developing Openlayers toolbar in Javascript with jQuery and jQuery UI.</p> <p>One feature that I want to implement is Adding points to the map.</p> <p>In openLayers you have to listen for event called 'sketchcomplete'.</p> <pre><code>layer.events.on({ 'sketchcomplete': onPointAdded }); </code></pre> <p>The problem is in onPointAdded callback. This callback should return true or false. True mean that the point should be added to the map and false means cancel adding this point to the map.</p> <p>Now the callback looks like this:</p> <pre><code>onPointAdded = function(feature) { var f = feature.feature; var result = false; $('#dialog-point-add').dialog({ modal : true, buttons : { 'Add point' : function() { result = true; $(this).dialog("close"); }, 'Cancel' : function() { result = false; $(this).dialog("close"); } } }); return result; }; </code></pre> <p>The problem is that this dialog doesn't block the executing code. I'm asking You How to handle this situation? I want to show dialog to the user with confirmation for adding the point.</p>