Danneh123
(Danny Schoemaker)
November 24, 2010, 9:58am
1
Hello everyone,
I was wondering how I could update two id’s (each with it’s own function) with only one ajaxlink.
My current solution:
echo CHtml::ajaxLink('display','functionurl',array('update'=>'#id1,#id2'));
at the moment both id’s are updated by the same function, is there a way to make a function for updateing #id1 and another function for updateing #id2 ?
Thanks in advance!
zaccaria
(Matteo Falsitta)
November 24, 2010, 10:52am
2
The action has to be unique, you must create a function actionFunctionurl.
In this function you can call as function you wish, for example:
public function actionFunctionurl($id1, $id2)
{
$this->updateFirst($id1);
$this->updateSecond($id2);
}
Then you have to implement the two update function.
The action as it I wrote will answer to such an url:
echo CHtml::ajaxLink('display','functionurl',array('id1'=>'#id1','id2'=>'#id2'));
This will avoid you to use explode or other function for separate your 2 parameters.
Danneh123
(Danny Schoemaker)
November 24, 2010, 10:59am
3
Thanks a lot!
Sounds really logical now you explain it to me.
Danneh123
(Danny Schoemaker)
November 24, 2010, 12:51pm
4
I’ve tried playing with the code / information you posted but I can’t seem to get it to work :S could you help me more detailed please?
Thanks in advance!
zaccaria
(Matteo Falsitta)
November 24, 2010, 12:59pm
5
What exactly are you going to do?
P.S: welcome to the forum!
Danneh123
(Danny Schoemaker)
November 24, 2010, 1:08pm
6
I have two div’s that need to be updated with one link
<div id="box_idhere">
<img src="urlhere"></img>
</div>
<div id="info">
info here
</div>
the box div is to display if a company is selected (when the ajax link is clicked this will be changed to another image which displays a selected box)
the info div displays a companies info.
these two div’s need to be updated with a single button click.
Thanks for the warm welcome
zaccaria
(Matteo Falsitta)
November 25, 2010, 1:44pm
8
You can do like that:
<?php CHtml::link('name', '', array('onClick'=>
CHtml::ajax(... first ajax request...).
CHtml::ajax(... second ajax request...)
))?>
In this case you will have the js for the ajax request to be executed one by one, and this should do the trick.
Danneh123
(Danny Schoemaker)
November 26, 2010, 8:56am
9
Thanks a lot, it certainly did the trick