0

I'm working with a Yii ajaxLink:

echo CHtml::ajaxLink(
'Toggle',
Yii::app()->createUrl('Tweet/toggleTag'),
array(
    'type' => 'POST',
    ...
    'data' => array('tagID'=>$data->tagID)
    ...

What I want to do is make the link toggle the tag (client and server side). I have a class that marks the element, but I'm not sure how to get access to that and pass it to the data parameter via Yii.

The link gets a 'hasTag' class when it has a tag.

I could just check if the tag is enabled on the server, but that doesn't seem like the right answer to me.

How can I toggle the tag based on its client side state?

1 Answer 1

2

Perhaps not the best answer, but it works...

I was able to use beforeSend to alter the data parameter:

'beforeSend'=>"function(){
    var myData = <whatever logic needs to be executed>;
    this.data += '&hasTag='+myData;
}",
Sign up to request clarification or add additional context in comments.

3 Comments

You'll need to be more specific.
nothing gets added to this.data i had to append to this.url
Well it has been three years since this answer was posted. I suppose Yii might have changed. If so your comment should help anyone else who wanders by!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.