How to call an Html.Action ("my_page") via jquery?

0

I have a page that loads several partials views, I want to call a specific page in a modal that will fill the entire screen. I'm using a generic jquery command to call an action that will be passed by parameters.

This is the

<button type="button" class="btn glyphicon glyphicon-zoom-in loopa" data-id="_ArquivosProcDia"></button>

This is the div

<div class="modal fade" id="modal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="modal-body" id="abrezoompagina">
                @Html.Action("_ArquivosProcDia")
            </div>
        </div>
    </div>
</div>

This is the script

<script>
$(".loopa").click(function () {
    var part = $(this).attr("data-id");
    var part2 = $(this).replaceWith(@(Html.Action(part));
    $("#modal4").modal();
});

Each partial view will have its own magnifying glass to bring the modal with your information, the partial that will open in this example will be the _Proc files .

    
asked by anonymous 07.03.2016 / 21:38

2 answers

2

I do not quite understand what your code does, but in my systems I usually grapple modal in HTML like this:

        <script type="text/javascript">
            $("#meu-botao").click(function () {
                $.get(@Url.Action("_ArquivosProcDia"), function (template) {
                    $("#alguma-div").append(template);
                    // Aqui coloco um código pra chamar a Modal.
                });
            });
        </script>

Either way, your code will not work. In order to work, it would have to be something like this:

$(".loopa").click(function () {
    var part = $(this).attr("data-id");
    var part2 = $(this).replaceWith(@Url.Action(part));
    $("#modal4").modal();
});
    
07.03.2016 / 22:57
0

I had to do this to work, but I'll have to repeat for each mode.

<script type="text/javascript">
$(".loopa").click(function () {
    var part = $(this).attr("data-id");
    $.get("@(Html.Raw(Url.Action("_ArquivosProcDia", "Home")))", function (template) {
        $("#abrezoompagina").replaceWith(template);
        $("#modal4").modal();
    });
});

    
08.03.2016 / 14:37