Posted By

joernroeder on 08/28/10


Tagged

confirm jquery dialog


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

randylien


confirm() to jQuery UI Dialog


 / Published in: JavaScript
 

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

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: SteveW1975 on September 4, 2010

hi, this would be ideal for me, do you have a sample html page which shows this being called as i am having problems getting this working.

Thanks

Steve

You need to login to post a comment.