I trigger to show the modal when user click on some element and ask them to make a choice.
Currently is to choose one color out of two.
And then I will use the color selected to create some element and add to the document.
I tried to use global variable to store the choice but that is too slow for my element creation.
Is there a synchronize way to wait for the modal to return value?
The following is invoked when user click on a specific element
-
- var SelectedColor = '#0000FF'; //global variable
- function CreateRoute(marker) {
- //create route
- var vertex = [];
- vertex.push(marker.getLatLng());
- //Block here and ask for color
- SelectedColor = null;
- $("#ChooseColor").dialog('open');
- //this one should wait callback
- var polyline = createGPolyline(vertex, SelectedColor, 5, 0.5);
-
- $gmap.addOverlay(polyline);
- polyline.enableDrawing({});
- GEvent.addListener(polyline, "endline", function() { BindEditRoute(polyline) });
- GEvent.addListener(polyline, "lineupdated", function() { UpdateRoute(polyline) });
- }
What should I do to work around this?