alert() to jQuery UI Dialog


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.