Update modal content dynamically

1

I have a table with up to 10 listed services, and each row has an update button. When you click the refresh button, a modal window opens with the data in this row, as well as a form for change.

However, I can not get the controller to return a partial view when the button is clicked and open the modal window with the updated data. I'm using bootstrap for the frontend.

FrontEnd Code Snippet:

<tbody>
    @foreach (var item in Model)
    {
        <tr>
            <td><input type="checkbox" class="checkthis" /></td>
            <td>@item.Chave</td>
            <td id="Nome @item.Chave">@item.Nome</td>
            <td>
                <p>
                    <a href="@Url.Action("Atualizar","Servico", new {chave = item.Chave})" class="btn btn-primary btn-xs atualizar" data-title="Edit" data-toggle="modal" data-target="#edit" data-placement="top" rel="tooltip"><span class="glyphicon glyphicon-pencil"></span></a>
                </p>
            </td>
        </tr>
    }
</tbody>

According to the above code, I need to click on the precise one to open a modal with the line service data.

The above code only accesses the controller and returns the partial view, but how can I open a modal from this? Is it possible with Ajax?

    
asked by anonymous 20.09.2014 / 02:07

1 answer

1

It is possible. By the way, there is an implementation in CodePlex where this is done as an extension:

  

link

With it, you can place a link to your Modal like this:

@Ajax.ModalDialogActionLink("Clique aqui para abrir seu modal", "Dialog1", "Dialog1")

The full explanation is here .

If you need me to package this as a NuGet, just let me know that I update the answer here with the package.

    
20.09.2014 / 17:28