Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pop up jquery dialog box
- <script type="text/javascript">
- $(document).ready(function () {
- $(".openDialog").live("click", function (e) {
- e.preventDefault();
- $("<div></div>")
- .addClass("dialog")
- .attr("id", $(this).attr("data-dialog-id"))
- .appendTo("body")
- .dialog({
- close: function () {
- $(this).remove();
- },
- modal: true
- })
- .load(this.href);
- });
- $(".close").live("click", function (e) {
- e.preventDefault();
- $(this).closest(".dialog").dialog("close");
- });
- });
- </script>
- $('body').on('click', '.openDialog', function (e) {
- e.preventDefault();
- var link = $(this);
- $("<div></div>")
- .addClass("dialog")
- .attr("id", $(link).attr("data-dialog-id"))
- .appendTo("body")
- .dialog({
- modal: true
- })
- .load($(link).attr('href'), {
- html: "<p>Text echoed back to request</p>"
- });
- });
- $('body').on("click", '.close', function (e) {
- e.preventDefault();
- $(this).closest(".dialog").dialog("close");
- });
- $("<div></div>")
- $("<div><div style='text-align: center'><img src='@Url.Content("~/Content/images/loading.gif")' alt='Please Wait...' width='100px'/></div></div>")
- // these are for the popup dialogs
- // need to use live instead of click because object doesnt exist on ready and will give an objectexpected
- $(".openDialog, .editDialog").live("click", function(e) {
- e.preventDefault();
- // this div is duplicate of 'loading' div below
- $("<div><div style='text-align: center'><img src='@Url.Content("~/Content/images/loading.gif")' alt='Please Wait...' width='100px'/></div></div>")
- .addClass("dialog")
- .attr("id", $(this).attr("data-dialog-id"))
- .appendTo("body")
- .dialog({
- // NOTE: This is where the size of the popup window is set
- width: 800,
- position: 'top',
- title: $(this).attr("data-dialog-title"),
- close: function() { $(this).remove(); },
- modal: true
- })
- .load(this.href);
- });
Advertisement
Add Comment
Please, Sign In to add comment