M
M
Maxim Timofeev2016-05-31 15:04:46
Yii
Maxim Timofeev, 2016-05-31 15:04:46

How to implement algorithm for pjax form?

There is a view in it, form1 in form1 there is a dropdown with cities, next to the "add city" button, when clicked, a modal opens, ajax is sent, we get form2 adding a city to the modal. Next, you need to submit form2 and update the dropdown in form1.
What is my problem:
if the modal is outside form1, it will not be possible to launch pjax of a piece of code with a dropdown;
if the modal is inside form1, then form2 is inside, and therefore submit works on form1
Probably you need to devour and look at the problem with a working brain. But maybe someone with a working brain "pokes his nose"?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2016-05-31
@webinar

Dismantled pjax piece by piece. And everything became clear. You can update another block with $.pjax.reload on successful pjax

$this->registerJs("
    $('#city_modal_forma').on('pjax:end', function() {
            $('#ajax-form').modal('hide');
            $.pjax.reload({container:'#city_dropdown'});
        });       
    ");

A
Abdula Magomedov, 2016-05-31
@Avarskiy

Avoid pjax. Use the $.ajax() function from jQuery. And load the answer into the element you need.

$.ajax({
  url: "some.php",
  success: function(data){
    $("селектор").html(data);
  }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question