Guest User

Untitled

a guest
May 9th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. pop up jquery dialog box
  2. <script type="text/javascript">
  3.  
  4. $(document).ready(function () {
  5. $(".openDialog").live("click", function (e) {
  6. e.preventDefault();
  7.  
  8. $("<div></div>")
  9. .addClass("dialog")
  10. .attr("id", $(this).attr("data-dialog-id"))
  11. .appendTo("body")
  12. .dialog({
  13. close: function () {
  14. $(this).remove();
  15. },
  16. modal: true
  17. })
  18. .load(this.href);
  19. });
  20.  
  21. $(".close").live("click", function (e) {
  22. e.preventDefault();
  23. $(this).closest(".dialog").dialog("close");
  24. });
  25. });
  26. </script>
  27.  
  28. $('body').on('click', '.openDialog', function (e) {
  29. e.preventDefault();
  30.  
  31. var link = $(this);
  32.  
  33. $("<div></div>")
  34. .addClass("dialog")
  35. .attr("id", $(link).attr("data-dialog-id"))
  36. .appendTo("body")
  37. .dialog({
  38. modal: true
  39. })
  40. .load($(link).attr('href'), {
  41. html: "<p>Text echoed back to request</p>"
  42. });
  43. });
  44.  
  45. $('body').on("click", '.close', function (e) {
  46. e.preventDefault();
  47. $(this).closest(".dialog").dialog("close");
  48. });
  49.  
  50. $("<div></div>")
  51.  
  52. $("<div><div style='text-align: center'><img src='@Url.Content("~/Content/images/loading.gif")' alt='Please Wait...' width='100px'/></div></div>")
  53.  
  54. // these are for the popup dialogs
  55. // need to use live instead of click because object doesnt exist on ready and will give an objectexpected
  56. $(".openDialog, .editDialog").live("click", function(e) {
  57. e.preventDefault();
  58.  
  59. // this div is duplicate of 'loading' div below
  60. $("<div><div style='text-align: center'><img src='@Url.Content("~/Content/images/loading.gif")' alt='Please Wait...' width='100px'/></div></div>")
  61. .addClass("dialog")
  62. .attr("id", $(this).attr("data-dialog-id"))
  63. .appendTo("body")
  64. .dialog({
  65. // NOTE: This is where the size of the popup window is set
  66. width: 800,
  67. position: 'top',
  68. title: $(this).attr("data-dialog-title"),
  69. close: function() { $(this).remove(); },
  70. modal: true
  71. })
  72. .load(this.href);
  73. });
Advertisement
Add Comment
Please, Sign In to add comment