Jump to content

Custom Alert doesn't work in JQuery UI


pintee

Recommended Posts

Hi,

As the title states, I am encountering a weird bug in javascript. In my php I am echoing out javascript that renders a jquery popup alert box to the screen.

echo '<link rel="stylesheet"   
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
                <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
                <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
                <link rel="stylesheet" href="/resources/demos/style.css" />
                <script src="../functions.js"></script>
                <script type="text/javascript"> $(document).ready(function() { JQueryAlert("POO!", 120); }); </script>';

functions.js

 function JQueryAlert(message,windowHeight){
    if (!windowHeight) var windowHeight = 470;

    $("#msgdialog").remove();

    $("body").append("<div id=\'msgdialog\'></div>"); 

    thatmsg = $("#msgdialog");

    $("#msgdialog").dialog({
        resizable: false,
        draggable: false,
        width: 770,
        height: windowHeight,
        context: thatmsg,
        modal: true,
        autoOpen: false,
        buttons: {
            "Cancel" : function (){
                thatmsg.dialog("close");
            },
            "OK" : function (){
                loadPage("combat.php");
            }
        }
    });     

    $("#msgdialog").html(message);
    $("#msgdialog").dialog(\'open\');
}

However, it only displays the pop up alert box sometimes. The rest of the time the screen just flashes and doesn't display the pop up box. Any ideas why it is behaving this way?? Thanks for your time.

 

Link to comment
Share on other sites

Another thing to consider is the (context: thatmsg) is thatmsg globally defined?

 

 

thatmsg = $("#msgdialog");

 

Right there.

 

Edit: Sorry, didn't see the globally part.

Edited by Irate
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.