Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have found after MUCH messing the best way is this as an easy way of emulating the javascript native alert using the dialog ui, is done as follows (which incidentally I wrote myself, because there is a high scarcity of usable stuff on this subject and lots of people whittering on about using plug ins, make a multi stage 'this' or irritating 'that' ZZZzzz...):</p> <p><strong>NB: You can't really do a equivalent of the confirm() function - without fass but you can use html rich alerts and add the events for that rich html yourself at the end of the jQueryAlery() call.</strong></p> <p>it works fine and includes a optional debug for 'viewing' the html or the 'url' in the case of the latter</p> <pre><code>function JQueryAlert(message,windowHeight){ /**** * equivalent to javascript 'alert' */ if (!windowHeight) var windowHeight = 470; $("#msgdialog").remove(); $("body").append("&lt;div id='msgdialog'&gt;&lt;/div&gt;"); thatmsg = $("#msgdialog"); $("#msgdialog").dialog({ resizable: false, draggable: false, width: 770, height: windowHeight, context: thatmsg, modal: true, autoOpen: false, buttons: { "Cancel" : function (){ thatmsg.dialog("close"); }/*, "View Source" : function (){ alert($('&lt;div&gt;').append($(this).clone()).html()); }*/ } }); $("#msgdialog").html(message); $("#msgdialog").dialog('open'); } </code></pre> <p>same as above except it goes and gets the content from a url</p> <pre><code> function JQueryHTML(url,windowHeight){ /**** * equivalent to javascript 'alert' but gets a url */ if (!windowHeight) var windowHeight = 470; $("#dialog").remove(); $("body").append("&lt;div id='dialog'&gt;&lt;/div&gt;"); that = $("#dialog"); $("#dialog").dialog({ resizable: false, draggable: false, width: 770, height: windowHeight, context: that, modal: true, autoOpen: false, buttons: { "Cancel" : function (){ that.dialog("close"); }/*, "View Source" : function (){ alert($('&lt;div&gt;').append($(this).clone()).html()); }, "View Url" : function (){ alert(url); }*/ } }); $.get(url, function(data) { $("#dialog").html(data); $("#dialog").dialog('open'); }); } </code></pre> <p>edit: </p> <p>I use it with the following PHP to great effect</p> <pre><code> if ($_SESSION['alert_message']){ echo "&lt;script&gt;\n"; echo " $(function() { \n"; echo " JQueryMessage('".str_replace("'","\'",$_SESSION['alert_message'])."'); \n"; echo " }); \n"; echo "&lt;/script&gt;\n"; unset($_SESSION['alert_message']); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload