2

I am using YiiBooster extension in yii.

I have created a form using 'booster.widgets.TbActiveForm', it works like a charm Now I just want to submit my form with ajax and update a grid

let's consider that

  • my form id = myform
  • my grid id = mygrid

I have the following code for the submit button in the form

       $this->widget(
                        'booster.widgets.TbButton',
                        array(
                            'context' => 'primary',
                            'label' => 'Add',
                            'buttonType' => 'ajaxSubmit',
                            'url' => Yii::app()->createUrl('myController/myAction',array('id'=>$model->deal_id)),
                            'ajaxOptions' => array(
                                'type' => 'POST'
                            )
                        )
                    );

the AJAX works like a charm, but where do I put the grid update code after the ajax call is returned to the client side?

$.fn.yiiGridView.update('mygrid');

I also check the TbButton api documentation but I could not find a solution.

My last resort would be to hook a jQuery click function with my submit button and make the AJAX call myself, but I am hoping for a better solution.

2
  • @lin when you're editing posts please take the time to fix all the issues, not just a single, trivial one. Commented Oct 5, 2014 at 22:45
  • @Flexo, I try it. I'am native. Because of this I dont correct spelling/gramma mistakes. ;) I hope you understand this. Commented Oct 6, 2014 at 8:07

1 Answer 1

4
$this->widget(
        'booster.widgets.TbButton',
        array(
            'context' => 'primary',
            'label' => 'Add',
            'buttonType' => 'ajaxSubmit',
            'url' => Yii::app()->createUrl(
                    'myController/myAction',array('id'=>$model->deal_id)
            ),
            'ajaxOptions' => array(
                'type' => 'POST',
                'success' => 'function(data) { 
                                $.fn.yiiGridView.update("mygrid");
                }',
            )
        )
);
Sign up to request clarification or add additional context in comments.

8 Comments

well before reading i knew it wont work and i was right because the TbButton class does not have such index for ajaxOptions array. You can download the extension and see line no #343 - #348 on TbButton class ------ btw i tested it also didnt worked
aaaa in yiiboster not worked yhis optin use boostrap cniska.net/yii-bootstrap or write native ajax call
now i have developed the whole project on yiibooster cant change, but the point is if they provide option for ajaxSubmit how to get control of that - to me thats strange .
one minut i change answer try this
i know this will work i am using it know, btw your previous anwsere works i was using the wrong id for the grid :) thnx mate chng ans so that i can mark as helpful :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.