1
<script type="text/javascript">

    $.ajaxSetup({ cache: false });

    $(document).ready(function () {
        $(".openPopup").live("click", function (e) {
            e.preventDefault();
            debugger;
            $("<div></div><p>")
            .addClass("dialog")
            .attr("id", $(this)
            .attr("data-dialog-id"))
            .appendTo("body")
            .dialog({
                title: $(this).attr("data-dialog-title"),
                close: function () { $(this).remove(); },
                modal: true,
                height: 250,
                width: 900,
                left: 0

            })
            .load(this.href);
        });

        $(".close").live("click", function (e) {
            e.preventDefault();
            $(this).closest(".dialog").dialog("close");
        });
    });
</script>

My Calling razor syntax is given below :-

 @Html.ActionLink("open modal popup", "About", "Home", null, new { @class = "openPopup", data_dialog_id = "popuplDialog", data_dialog_title = "Popup"})
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
janakiramA
  • 21
  • 2

1 Answers1

0

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers in new jQuery versions. There is a issue in your code, $("<div></div><p>") should be $("<div></div>")

$.ajaxSetup({ cache: false });

$(document).ready(function () {
    $(".openPopup").on("click", function (e) {
        e.preventDefault();
        $("<div></div>")
        .addClass("dialog")
        .attr("id", $(this).attr("data-dialog-id"))
        .appendTo("body")
        .dialog({
            title: $(this).attr("data-dialog-title"),
            close: function () { $(this).remove(); },
            modal: false,
            height: 250,
            width: 900
        })
        .load(this.href);
    });
});

JSFiddle

Saranga
  • 3,178
  • 1
  • 18
  • 26
  • Thanks for ur suggestion, i tried it got popup but once i close and click again it is loading multiple instances. and in jsfiddle if we close and click onpe again nothing is happening why ?. these are the issue i cant figure it. pl guide me. – janakiramA Aug 03 '14 at 17:15
  • It seems `left` is not an `option` for `dialog`. (http://api.jqueryui.com/dialog/) I have updated the answer. – Saranga Aug 04 '14 at 04:20