Reload Pjax Grid In Modal


I am showing a grid in a modal.

I am using a form and ajax button to add items to the db table in which the grid gets data from.

I want to refresh the grid after posting using pjax.

I have this working on normal page but can not get it to work within the modal.

Is this possible or should i stop now?



I have setup a modal with gridview and pjax inside. So it should work in general.

Need more information to see where the problem might be.

Thanks for response, good to know that it does work.

in summary here is what i have…

modal is called,

there is a dropdown selector in the modal to choose between options

button to choose option is ajax call

upon success, variables are returned,

based on variables <div id=???> is shown

within that div there is a 1. xeditable area, 2. pjax-begin containing "echo GridView::widget…", pjax-end

then an active form with "echo Typeahead::widget([…"

then an “echo Button::widget([…” that has associated “$this->registerJs(’…$(”#addOptionBtn").click(function() {" ajax to call server.

upon success response reload the pjax container "$.pjax.reload({container: "#options-pjax", timeout: 2000});"

I have been over and over to see if i can find an error in div tags or such but still no luck.

Are you able to share your test with me so i can review and compare components?



*** I have found the solution ***

The ajax button that i had to post the updates was within the activeform which submitted each time. pulled it out and looks like i can get it to work correctly.


The reason for this is that HTML defaults a button type to submit. So something like this

Html::button($label, $options); // will default to a submit button

You can set/override the right button type and use the ajax button within the ActiveForm tags as well:

$options['type'] = 'button'; //make it a normal button

Html::button($label, $options);