Set multiple title on common modal popup window on button click in mvc

Total Post:4

Points:28
C#
 582  View(s)
Ratings:
Rate this:

Hi Expert,

                Here is my code. i am open common modal popup on different button click. I want to set title of modal popup on button click.

<a class="btn btn-primary btn-sm pull-right openDialog" style="margin-top:-5px;margin-bottom:-3px" href="@Url.Action("Add")"><i class="fa fa-plus"></i></a>
$(document).on("click", ".openDialog", function (e) {


        e.preventDefault();

        var me = this;

        var option = { "backdrop": "static", keyboard: true };

        $.ajax({

            type: "GET",

            url: $(this).attr("href"),

            success: function (data) {

                $('#modelContent').html(data);

                $('#modelDialog').modal(option);

                $('#modelDialog').modal('show');

            }

        });

    });

Please give me some idea to achieve this task.

  1. Post:44

    Points:310
    Re: Set multiple title on single modal popup window on button click in mvc

    Hello Aarav,

                        I analyzed your code. Please follow below modified line of code in your project.

    <a class="btn btn-primary btn-sm pull-right openDialog" title="Add Candidate" style="margin-top:-5px;margin-bottom:-3px" href="@Url.Action("Add")"><i class="fa fa-plus"></i></a>
    $(document).on("click", ".openDialog", function (e) {
    
            e.preventDefault();
            var me = this;
            var option = { "backdrop": "static", keyboard: true };
            $.ajax({
                type: "GET",
                url: $(this).attr("href"),
                success: function (data) {
                    $('#modelContent').html(data);
                    $('#modelDialog').find('.modal-title').html($(me).attr("title"));
                    $('#modelDialog').modal(option);
                    $('#modelDialog').modal('show');
                }
            });
        });

     Hope its informative for you !!          

Answer