Page Reload After Bootstrap Tbmodal Usage

Hello fellow Yii-experts,

I have an Yii application with installed Yii-Bootstrap-extension.

Within a tbmodal I have a form. After (ajax-)submitting the form and using the form-data, I want to refresh the whole page on which the modal is placed.

Unfortunately I don’t get it to work. Things like Yii:app()->refresh()or redirect load properly, but only in a hidden frame visible inside Firebug, the main page is not influenced.

Is it possible to refresh the main page in which the tbmodal is placed after submitting the form inside the tbmodal?

I am thankfull for every hint!

I’m a relatively newbie in Yii, and I had been looking for an answer to this same question, but wasn’t able to find any resolution.

Tried a few things, but eventually this worked. You might had found a solution since this had been posted for quite a while, but nevertheless, hopefully this prove useful for later comers.

At the modal-footer, you usually have a couple of buttons (OK and Cancel) and the OK will have a URL that it will direct to an action, and here is the setup.

$this->widget('bootstrap.widgets.TbButton', array(


    'label'=>'OK',


    'type'=>'primary',


    'htmlOptions'=>array(


        'data-dismiss'=>'modal',


        'onclick'=>"js:$.ajax({'url':\"$url\",async:false});location.reload();",


    ),


)); 

Keys:

  1. the ajax call should be async:false, so that the action is finished before proceeding.

  2. location.reload() refreshes the page.

There may be more efficient way to do this, I don’t know.

Hope this helps.