Hi, i need to display my file in single page. In my application i’ve some options, when i click option i need to display anothe page in the same page only.
Here i'm attaching my files. Here i've seeting page inthat when i click change password the password page need to display in setting page only by using ajax. can i know how to use ajax here?
Hi there,
First Step
<div class="inner_tab_contant">
Passwrid page
</div>
Second Step in password page
<?php echo CHtml::ajaxLink(' Add Artist', array('artist/addartist?vid=' . $vid), array('update' => '.inner_tab_contant'), array("live" => false)); ?>
Third Step
Then you can create the action in your controller and render the setting page
public function actionaddartist(){
$this->render('setting');
}
Best Regards,
Ankti Modi
Hi,
if you want to replace setting.php with password.php,
make like,
in setting.php
<html>
<body><br><br><br>
<table>
<div id="anyid">
<table align="left">
</table>
</div>
</table>
</body>
</html>
and you want to keep your <table> data
so put that <div id="anyid"> after </table> tag
Now,
call ajax on click button
ajax call in javascript
$.ajax({
type: 'GET',
url: '<?php echo CController::createUrl('controlelr/action'); ?>',
asyc: false,
data: {'c': c},
success: function(data) {
if(data){
$('#anyid').html(data);
}
}
});
in controller action–
call your password page like
$this->renderPartial('password',array('model'=>$model));
No. i don’t need to replace in setting page. In setting page i’ve Change Password link, when i click link the password page also need to display in setting page with functionality of Change Password.
1) Just change link to ajax link in your setting.php
<?php echo CHtml::ajaxLink(' change password', array('/user/password'), array('update' => '.inner_tab_contant'), array("live" => false)); ?>
[b]2) At the end of page you can append the div
just add the div at the end of page[/b]
<div class="inner_tab_contant"></div>
3) in your user controller renderpartial page
=>$this->renderPartial('/user/password', array('model' => $model,true,false));
[b]BestRegards,
Ankit Modi[/b]
1) Just change link to ajax link in your setting.php
<?php echo CHtml::ajaxLink(' change password', array('/user/password'), array('update' => '.inner_tab_contant'), array("live" => false)); ?>
[b]2) At the end of page you can append the div
just add the div at the end of page[/b]
<div class="inner_tab_contant"></div>
3) in your user controller renderpartial page
=>$this->renderPartial('/user/password', array('model' => $model,true,false));
[b]BestRegards,
Ankit Modi[/b]
Dear Ankit Modi,
In userController where i need to change.
In your Usercontroller go to actionpassword and add one line before close the action bracket
$this->renderPartial('/user/password', array('model' => $model,true,false));
In your Usercontroller go to actionpassword and add one line before close the action bracket
$this->renderPartial('/user/password', array('model' => $model,true,false));
Dear Ankit Modi,
Now i am getting in the same page, but when i click button my page action is showing in anothe page. it showing like this in my anothe page
Fields with * are required.
Current Password *
New Password *
Confirm Password *
BUt, my password is saving successfully. But, i need to show in same page.
Hi, i changed render, it displaying same page. But, it showing anothe page when i click submit button.
When click submit button i need to stay in same page
u can chnage this line in your password form
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'changePass-form',
'type' => 'horizontal',
'enableAjaxValidation' => false,
'htmlOptions' => array(
'onsubmit' => "return false;",
),
));
?>
u can chnage this line in your password form
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'changePass-form',
'type' => 'horizontal',
'enableAjaxValidation' => false,
'htmlOptions' => array(
'onsubmit' => "return false;",
),
));
?>
Hi, when i gave like this My submit button action is not working.
yes i know because it’s return false so u can just add the line validate on submit using [b]clientoptions
[/b]
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'changePass-form',
'type' => 'horizontal',
'enableAjaxValidation' => false,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'htmlOptions' => array(
'onsubmit' => "return false;",
),
));
?>
yes i know because it’s return false so u can just add the line validate on submit using [b]clientoptions
[/b]
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'changePass-form',
'type' => 'horizontal',
'enableAjaxValidation' => false,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'htmlOptions' => array(
'onsubmit' => "return false;",
),
));
?>
No, Sir, Now also submit action is not working. when i click submit it’s nothing happend?
and finally last change the line in your password action
$this->renderPartial('/user/password', array('model' => $model),false,true);
hope this help
Now also action is not working, sir. if i put comments to htmlOptions the action is working, but, the page is displaying in another page.
Sorry, sir, i’m not getting, from where i need to add onclick function here…
<?php echo CHtml::link(‘Change Password’, array(’/user/password’, ‘id’ => app()->user->id), array(‘update’ => ‘.inner_tab_contant’), array(“live” => false)); ?>
First change the line on password.php
<?php echo CHtml::link('Link Text',array('user/password?id=942'),array('class'=>'aa','onclick'=>'test()')); ?>
and add the function
<script>
function change(id) {
if (id != '') {
$.ajax({
type: "GET",
url: "<?php echo Controller::createUrl('/users/password') ?>",
data: {"id": id},
async: false,
success: function(data) {
$('.inner_tab_contant').html(data);
},
});
}
}
</script>
ohhh, Its opening in new page and also action is not working.