MVC 5 Ajax.ActionLink returns result, but does not render in DOM

1

Gentlemen, I'm having trouble displaying a list of results in my view.

The idea is, when I click on a value from a dropdown, I make an asynchronous query to populate the next dropdown. I would refer to the controller by the Ajax.ActionLink method, why do not I want to reload the page, or display the id in the url:

<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">

                            int count_pai = 0;

                            while (count_pai < LPPai.Count)
                            {
                                <li>
                                    @Ajax.ActionLink(LPPai[count_pai].valor, "AbrirChamado", new { id_pai = LPPai[count_pai].id }, null, new AjaxOptions()
                               {
                                   HttpMethod = "GET",
                                   UpdateTargetId = "dropdown_menu_problemas_filho",
                                   InsertionMode = InsertionMode.Replace
                               })
                                </li>

                                count_pai++;
                            }
                        }

</ul>

Then when I click on a "li" element, I send the element id to the controller and return the search result to the target DOM "dropdown_menu_problemas_filho".

The search return should be rendered in the element below:

<ul id="dropdown_menu_problemas_filho" class="dropdown-menu" aria-labelledby="dropdownMenu1">

                        @if (LPFilho != null)
                        {
                            int count_filho = 0;

                            while (count_filho < LPFilho.Count)
                            {
                                <li>@LPFilho[count_filho].valor</li>

                                count_filho++;
                            }
                        }
</ul>

And debugging the view by the razor, the list is actually populated:

Sofarsogood.Theproblemis,afterthat,nothinghappens!NovalueisrenderedintheDOM,evenifthereisnoerror,andtheloopterminatingwithoutanyproblems.

I've already tried displaying the values with @Html.DisplayText, putting only the @LPFile [count_filho] .valor without tags, and everything else! Nothing works.

Does anyone have any idea why values are not rendered? Is there a better (or more correct) way of doing this? Many thanks.

    
asked by anonymous 07.01.2017 / 18:56

1 answer

1

I do not know what you care about .. but please install jQuery.Unobtrusive.Ajax

search on Nuget manager: "Microsoft.jQuery.Unobtrusive.Ajax" searches for the latest version.

    
09.01.2017 / 12:29