Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Bootstrap Button + Ajax + Modal

$
0
0
I have created a TbButton which works fine
$this->widget('bootstrap.widgets.TbButton',array(
        'buttonType' => 'ajaxLink',
        'id' => 'friendship',
        'type' => 'link',
        'label' => $relationship['cancel'],
        'size' => 'small',
        'url' => $this->createURL('/friendship/friendship/requests'),
        'disabled' => false,
        'ajaxOptions' => array(
                'type' => 'Post',
                'url' => $this->createURL('/friendship/friendship/requests'),
                'data' => Yii::app()->request->csrfTokenName."=".Yii::app()->request->getCsrfToken()."&action=cancel&user=".$model->username,
                'success'=>"js:function(vals){
                                $('#yt0').text('".Yii::t('profile','Add as a friend')."');
                                $('#yt0').attr('class','btn btn-warning btn-small');
                                $('#yt1').text('');
                       
                }",
                )
));


But how do I get the modal inside? I tried this:
$this->widget('bootstrap.widgets.TbButton',array(
	'buttonType' => 'ajaxLink',
	'id' => 'friendship',
	'type' => 'link',
	'label' => $relationship['cancel'],
	'size' => 'small',
	'url' => $this->createURL('/friendship/friendship/requests'),
	'disabled' => false,
	'htmlOptions'=>array(
        'data-toggle' => 'modal',
        'ajax' => array(
			'type' => 'Post',
			'url' => $this->createURL('/friendship/friendship/requests'),
			'data' => Yii::app()->request->csrfTokenName."=".Yii::app()->request->getCsrfToken()."&action=cancel&user=".$model->username,
            //'processData' => false,
			'success'=>"js:function(vals){ 
					$('#yt0').text('".Yii::t('profile','Add as a friend')."');
					$('#yt0').attr('class','btn btn-warning btn-small');
					$('#yt1').text('');
				
			}",
			),
        ),
));
but no success.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>