Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Modal Popup to show in center of screen
    text
    copied!<p>I am using the following jquery code to open a modal popup on click on an Action in MVC 3.</p> <p><strong>Action</strong></p> <pre><code>@Html.ActionLink("Change", "Settings", "Account", null, new { @class = "openDialog", data_dialog_id = "newPostDialog", data_dialog_title = "Change" }) </code></pre> <p><strong>Jquery</strong></p> <pre><code> $(document).ready(function () { $(".openDialog").live("click", function (e) { e.preventDefault(); $("&lt;div&gt;&lt;/div&gt;") .addClass("dialog") .attr("id", $(this) .attr("data-dialog-id")) .appendTo("body") .dialog({ title: $(this).attr("data-dialog-title"), close: function () { $(this).remove() }, modal: true, width:1020 }) .load(this.href); }); $(".close").live("click", function (e) { e.preventDefault(); $(this).closest(".dialog").dialog("close"); }); }); </code></pre> <p><strong>Problem</strong></p> <p>I am not able to position my modal popup in the center of the screen or align it with the top of the screen. </p> <p>I have tried this, but doesnt work.</p> <pre><code>dialog({ title: $(this).attr("data-dialog-title"), close: function () { $(this).remove() }, modal: true, width:1020, top:0, left:10 }) </code></pre> <p>Being a naive in jquery I am unable to find a solution to this. Can anyone please guide me in geting this.</p> <p>A default style of <code>style=display: block; z-index: 1002; outline: 0px none; position: absolute; height: auto; width: 1020px; top: 394px; left: 439px;</code> is added automaically, I just want to change <code>top</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload