PDA

View Full Version : "alert()" interrupts function



nora
21 Dec 2006, 12:42 PM
I had real problems to get my code working- now I've realised that if i eliminate all alerts in my code everything works fine?
any ideas?
this is my code:

function deleteMessage(){
var param=grid.getSelectedRowId();
alert('test');
dialog('delete',param); //function defined in another skript
}

var tb = new YAHOO.ext.Toolbar('example-toolbar');
tb.addButton({
text: 'delete',
click: deleteMessage
});

the alert works fine - but the code after the alert is never reached.
As soon as I remove the alert the function dialog() is reached and works fine.
thanks for help!

Animal
22 Dec 2006, 12:53 AM
How do you know it's not executing the following lines? Have you stepped through it in Firebug?

zquirm
22 Dec 2006, 1:23 AM
the alert function pauses the code...it won't continue until you click ok.

if you want to alert yourself when an event has happened without pausing the code, don't use alert and change the the background-color of an element instead, which you can do with Jack's Element.setStyle...or try anything else that's visual (change text, move an element, etc.)

hope that helps.

Animal
22 Dec 2006, 2:28 AM
Best thing is to log messages to Firebug's console.



YAHOO.widget.Logger.enableBrowserConsole();

....

YAHOO.log("test");

zquirm
22 Dec 2006, 10:52 AM
true story...