[Yii2] RenderAjax view that contains JavaScript registred

Hi all, i have a view (geoview) that get a model with some geo point (lat,long) and create a google map with these points as marker. To do that i use dosamigos\google\maps\Map that register a javascript as asset at the end of the page.

If i user this view in the classic way, rendered from a controller, it works fine.

Now i have a more complex situation.

  • Main Controller: index

  • it render a Main View: search

  • in this view i have a kartik\widgets\Select2 where my user can select different values

  • onchange, i call a controller "getgeo" that with the value selected, retrieve from my db a model with geo point (lat,long)

  • after that, my controller "getgeo" does a renderajax of my view "geoview" because i want to display the Select2 result in the same page.

My problem i that “geoview” is rendered with his asset at the center of the main view (search) and not at the end. In this way the javascript of dosamigos\google\maps\Map doesn’t work.

I hope to describe well my situation.

I don’t know how to renderajax a view and put his asset at the end of the main view.