Posted By

joernroeder on 08/28/10


Tagged

jquery alert dialog


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

randylien


alert() to jQuery UI Dialog


 / Published in: JavaScript
 

  1. /**
  2.  * Override javascript alert() and wrap it into a jQuery-UI Dialog box
  3.  *
  4.  * @depends $.getOrCreateDialog
  5.  *
  6.  * @param { String } the alert message
  7.  * @param { Object } jQuery Dialog box options
  8.  */
  9. function alert(message, options) {
  10.  
  11. var defaults = {
  12. modal : true,
  13. resizable : false,
  14. buttons : {
  15. Ok: function() {
  16. $(this).dialog('close');
  17. }
  18. },
  19. show : 'fade',
  20. hide : 'fade',
  21. minHeight : 50,
  22. dialogClass : 'modal-shadow'
  23. }
  24.  
  25. $alert = $.getOrCreateDialog('alert');
  26. // set message
  27. $("p", $alert).html(message);
  28. // init dialog
  29. $alert.dialog($.extend({}, defaults, options));
  30. }

Report this snippet  

You need to login to post a comment.