How to implement the algorithm for pjax form?

There are view it форма1 in форме1 have a dropdown with cities, next to the button "add city", when you click opens modelka is sent to ajax get a 2 add a city to modelco. Next you need to send 2 and update here calls a dropdown in форме1.
What I have a problem:
if modelka out формы1 - couldn't invoke pjax piece of code dropdown
if modelka inside формы1 - and форма2 inside, and therefore the submit is triggered on форму1

Probably need to eat and to see the brain working on the problem. But can someone with a working brain "tyknet nose"?
July 9th 19 at 10:13
2 answers
July 9th 19 at 10:15
Solution
Pjax was dismantled by cogs. And everything became clear. Possible by the successful pjax to update another block c by using $.pjax.reload
$this->registerJs("
 $('#city_modal_forma').on('pjax:end', function() {
$('#ajax-form').modal('hide');
$.pjax.reload({container:'#city_dropdown'});
 }); 
 ");
July 9th 19 at 10:17
Dispense with pjax. Use the function $.ajax() from jQuery. And upload the answer to your desired item.

$.ajax({
 url: "some.php",
 success: function(data){
$("selector").html(data);
}
});
I wanted to write something universal that would just use it in other places, and ajax will have to generate a new one here calls a dropdown that for each form will be different. In the case of pjax from itself parses the response and chooses what to update, what neymoverno convenient. But apparently did not succeed. I modelka 1 for the entire project and a script which loads it in the form, all data fields parametrized using button that it is, I would like to add a universal solution for pjax. - Henderson_Beat commented on July 9th 19 at 10:20
I have for such purposes, soy is a universal function. I don't know if it would fit you. You can write the details to me in vk - Cindy.Oberbrunner32 commented on July 9th 19 at 10:23
: A casket just opened. Pjax was dismantled by cogs. Possible by the successful pjax to update another block c by using $.pjax.reload:
$this->registerJs("
 $('#city_modal_forma').on('pjax:end', function() {
$('#ajax-form').modal('hide');
$.pjax.reload({container:'#city_dropdown'});
 }); 
 ");
- Henderson_Beat commented on July 9th 19 at 10:26

Find more questions by tags YiiPHP