Same partial view within multiple modal popup

Asked

Viewed 344 times

0

I have a content that is inside a partial view. There are situations where I need to open popup’s that change only buttons and their actions.

But the content is always the same as the partial view. I believe that when rendering the page, it is being created the same partial view for each popup and with it, the id’s of the HTML components repeat themselves. This messes up the whole code.

For example lose reference to grid, of tabpage.

Does anyone know how to repurpose it partial view in several popup’s?

<div id="divModal">
    @Html.Partial("DadosComuns")
</div>

<script>
    $(document).ready(function () {

        dialog-01 = $("#divModal").dialog({
            autoOpen: false,
            title: "Tela 01",
            modal: true,
            buttons: {
                "Ação A": function() {
                    AcaoA();
                },
                "Fechar ": function() {
                    dialog-01.dialog('close');
                }
            }
        })

        dialog-02 = $("#divModal").dialog({
            autoOpen: false,
            title: "Tela 02",
            modal: true,
            buttons: {
                "Ação B": function() {
                    AcaoB();
                },
                "Ação C": function() {
                    AcaoC();
                },
                "Fechar ": function() {
                    dialog-02.dialog('close');
                }
            }
        })

        dialog-03 = $("#divModal").dialog({
            autoOpen: false,
            title: "Tela 02",
            modal: true,
            buttons: {
                "Ação D": function() {
                    AcaoD();
                },
                "Ação E": function() {
                    AcaoE();
                },
                "Fechar ": function() {
                    dialog-03.dialog('close');
                }
            }
        })
    }
</script>
  • You need to create an example in code. I imagined what this is about, but I can’t be sure.

  • Vixi.... the code is too big.... I will try to summarize:

  • 1

    Do a [mcve].

  • This example I put above serves?

1 answer

0


I decided to change the id s of the HTML elements. Thus: $("#grid"). attr('id', 'grid-01');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.