Yii Framework Forum: Ajaxbutton In Two Sub Page, The Second Does Not Work - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Ajaxbutton In Two Sub Page, The Second Does Not Work Rate Topic: -----

#1 User is offline   dahuzizyd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 21-June 11

Posted 27 April 2013 - 08:12 AM

hi all:

I have a page named '_form.php' . In this page , i used a modal dialog(bootstrap extension).in the modal dialog.

I used bootstrap tab control extension in my page. Such as :
<?php  $this->widget('bootstrap.widgets.TbTabs', 
	array('type'=>'tabs', // 'tabs' or 'pills'
		'tabs'=>array(
			array('label'=>'Project','content'=>$this->renderPartial('_form',array('model'=>$model),true,true),'active'=>true ),
			array('label'=>'Member','content'=>$this->renderPartial('_check_user',array('model'=>$model),true,true),'visible'=>$model->isNewRecord ? 'false' : 'true')
			)
	));
?>

in sub page '_form', i hava a modal dialog named '_select_user' and an ajaxButton in it , i call it A_Button such as :
in '_form' :
<?php echo $this->renderPartial('_select_user'); ?>

in '_select_user':
<?php echo CHtml::ajaxButton('search', array('getUser'),
	array(//'success'=>'js:function(data){alert(data);}',
		'data'=>array('name'=>'js:$("#User_name").val()',
		'department_id'=>'js:$("#User_department_id option:selected").val()',
		'parent_form'=>'$("#modalType").val()'),
		'type'=>'POST',
		'update'=>'#user_list','return'=>true)
	,array('class'=>'btn btn-success btn-small'))?>


in sub page '_check_user', also have an ajaxButton in it,i call it B_Button,such as :
<?php echo CHtml::ajaxButton('search', array('getCheckUser'),
	array(//'success'=>'js:function(data){alert(123);}',
		'data'=>array('name'=>'js:$("#User_name_1").val()',
		'department_id'=>'js:$("#User_department_id_1 option:selected").val()'),
		'type'=>'POST',
		'update'=>'#user_list_from',
		'return'=>false)
	,array('class'=>'btn btn-success btn-small'))?>


Now, my problom is : click B_Button, there is nothing happened.
In page source . generated javascript is :
$('body').on('click','#yt1',function(){jQuery.ajax({'data':{'name':$("#User_name").val(),'department_id':$("#User_department_id option:selected").val(),'parent_form':'$(\"#modalType\").val()'},'type':'POST','return':true,'url':'/projectq/index.php?r=project/getUser','cache':false,'success':function(html){jQuery("#user_list").html(html)}});return false;});
jQuery('#modalManager').modal({'show':false});

$('body').on('click','#yt2',function(){jQuery.ajax({'data':{'name':$("#User_name_1").val(),'department_id':$("#User_department_id_1 option:selected").val()},'type':'POST','return':false,'url':'/projectq/index.php?r=project/getCheckUser','cache':false,'success':function(html){jQuery("#user_list_from").html(html)}});return false;});
jQuery('#yw0').tab('show');


if i comment A_Button , B_Button workes fine .
Or if i change B_Button' render before A_Button . B work fine , A does not work.

any ideas?

My native language is not english , I try my best to wrote this.

thanks all.
0

#2 User is offline   dahuzizyd 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 21-June 11

Posted 27 April 2013 - 09:25 AM

i found solution by myself but i don't know why:
chang the fourth parameter for renderPartial true -> false:

<?php  $this->widget('bootstrap.widgets.TbTabs', 
        array('type'=>'tabs', // 'tabs' or 'pills'
                'tabs'=>array(
                        array('label'=>'Project','content'=>$this->renderPartial('_form',array('model'=>$model),true,true),'active'=>true ),
                        array('label'=>'Member','content'=>$this->renderPartial('_check_user',array('model'=>$model),true,true),'visible'=>$model->isNewRecord ? 'false' : 'true')
                        )
        ));
?>


to:
<?php  $this->widget('bootstrap.widgets.TbTabs', 
        array('type'=>'tabs', // 'tabs' or 'pills'
                'tabs'=>array(
                        array('label'=>'Project','content'=>$this->renderPartial('_form',array('model'=>$model),true,false),'active'=>true ),
                        array('label'=>'Member','content'=>$this->renderPartial('_check_user',array('model'=>$model),true,false),'visible'=>$model->isNewRecord ? 'false' : 'true')
                        )
        ));
?>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users