Slow Start

My morning so far has not  followed my morning traditions. I wasn’t the first one up, so that started the chain reaction of lateness. I didn’t get to pack a lunch, I didn’t get to make my tea, I had to rush myself out the door. Of course, since it’s summer, I got to the same point in my drive at the same time as I normally do, so I decided to stop off and get a bendy drain because my new sink doesn’t quite reach the old plumbing (and I don’t want to dig into the wall to replace it). So now I won’t have to stop later. Of course that means I feel under caffeinated and hungry, I’ll have to make my post quick.

For the past few weeks, there has been a mystery javascript issue appearing on one of my projects. Using jQuery’s dialog, I created a special alert ‘button’ that will alert people to whatever it is the alert was meant to say instead of using the standard javascript alert, which is a standard operating system alert, and most people click OK or close without even looking at it. Anyway, so for the past few weeks I would make changes to it, and the result would still come back telling me that they have to drag it open because some of the text wasn’t showing, so I’d make it bigger and this would continue. After taking a fresh look at the code, I realized that the whole time what was happening was that it was using the previous popup dimensions. Basically, my code was creating a div that gets filled with all this information, then it gets shown in the middle of the screen (as dialogs are). Upon close, it does not get destroyed, so in my code I originally checked to make sure it didn’t exist, and that is the only time I’d try to create it. Well, when I tried sending along a new size dimension, it would work, just fine, as long as it was the first popup I tested. That’s where my confusion was happening. So, in the end, I wound up testing to see if the div existed, and if it did, I removed it, and just recreated the div, dimensions and all, each time.


function jqAlert(text){

var height = 200;
if (arguments.length == 2) height=arguments[1];
if( $("#popupDialog").length > 0){
$('#popupDialog').dialog("destroy");
$('#popupDialog').remove();
}
$("body").append('
'+text+'');
$('#popupDialog').dialog({
autoOpen: false,
modal:true,
height: height,
title: "ALERT",
buttons: {
'Ok': function() { $(this).dialog('close');return true;}
}
});
$('#popupDialog').dialog('open').html('
'+text+'

‘);
return true;
}