A
A
alex5e2014-06-23 08:37:52
Yii
alex5e, 2014-06-23 08:37:52

How to make ajax link in TbButtonGroup (YiiBooster)?

When creating a list via TbButtonGroup, ajax request does not work. It just refreshes the page and displays the response (no styling, styling, etc.), while with TbButton everything works fine. Here is the code:

$this->widget('bootstrap.widgets.TbButtonGroup', array(
            'size' => 'small',
            'buttons' => array(
              array(
                'label' => 'Действия',
                'visible'=>Yii::app()->getModule('user')->isAdmin(),
                'items' => array(
                array(
                'label'=>'Удалить',
                'buttonType' => 'button',
                'type'=>'warning',
                'url'=> Yii::app()->createUrl('Posts/Delete', array("id"=>$model->post_id)),
                'size'=> 'small',
               'htmlOptions'=>array(
                        'data-toggle'=>'modal',
                        'data-target'=>'#DeleteModal',
                        'style'=>"margin-top:10px;margin-left:35px;",
                    )),
                array(
                'label'=>'передать ВК',
                'buttonType' => 'ajaxButton',
                'type'=>'default',
                'size'=> 'small',
                'url' => Yii::app()->createUrl('posts/SendVK'),
                'ajaxOptions' => array(
                  'type'     => 'POST',
                  'success' => 'function(data)
                    {
                      var obj = $.parseJSON(data);
                      if (obj == null)
                      {
                        MessageBox.messageDelay("Произошла ошибка", "error");
                      }
                      else
                      {
                        MessageBox.messageDelay("Успешно", "success");
                      }
                    }',
                  'data' => array('post_id' => $model->post_id),
                  ),
               'htmlOptions'=>array(
                        'style'=>"margin-top:10px;margin-left:35px;",
                        )
                    ),
          ),
))));

Also, when using this widget, it is not possible to call the modal window.
Maybe someone faced similar problems?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question