Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Ash 5 posts 95 karma points
    Mar 05, 2018 @ 09:37
    Mike Ash
    0

    Ajax call inside a Partial view doesn't return the correct Culture(lang)

    Hey folks! I'm having an issue using Ajax call inside my Partial view to retun another Partial with correct language .. In other words, I have a partial which looks like this :

    <div class="container text-center">
    <nav class="submenu">
        <div class="container">
            <ul id="sub_ul">
                <li class="MenuLink">
                    <a id="a3" href="#" class="MenuLink">@Umbraco.GetDictionaryValue("about_us")</a>
                </li>
                <li class="MenuLink">
                    <a id="a4" href="#" class="MenuLink">CSR</a>
                </li>
            </ul>
        </div>
    </nav>
    

    and what I do with those sub links is that I load another partial view depending on which one is active/clicked ... which would be like this :

    $('#a3').click(function (e) {
            e.preventDefault();
            $('#content-submenu-o').load('@Url.Action("AboutUs", "Office")');
        });
    

    and of course in my controller , I have the simple Partial view return like :

     public ActionResult AboutUs()
        {
            if (Request.IsAjaxRequest())
            {
            return PartialView(PATH + "_aboutUs.cshtml");
            }
            return View();
        }
    

    my second partial view is as simple as this one :

        <div class="col-lg-8">
                <h2>@Umbraco.GetDictionaryValue("about_us_note")</h2>
            </div>
    

    so when the part of the page loads, It won't pick the english translation from my dictionary. For the first partial that I have, it works fine but the second partial that comes via ajax is not picking up the english translation at all , any tips?

    /cheers

  • Mike Ash 5 posts 95 karma points
    Mar 05, 2018 @ 12:45
    Mike Ash
    100

    Actually was able to work around it by getting the help from this post : Clicky

    I simply passed the CurrentUICulture from the controller to the view and consumed it via JavaScript on my partial \o/

Please Sign in or register to post replies

Write your reply to:

Draft