Thursday, September 29, 2011

Ajax Link - How to exchange/toogle a link?

Hi,

I have this part of code in my view

<div class="add_details" id="dynbookmark">
<?php if($this->Bookmark->checkBookmarkStatus($objects[0]
['Gesamtobjekt']['OBJ_ID']) == 'bookmark'){
$image = 'bookmark.png';
$text = __('Immobilie merken', true);
$action = 'add';
}else{
$image = 'bookmarked.png';
$text = __('Immobilie vorgemerkt', true);
$action = 'delete';
}
?>
<?=$ajax->link($this->Html->image($image).$text,
array('controller'=>'bookmark', 'action'=>$action, $objects[0]
['Gesamtobjekt']['OBJ_ID']), array('escape' => false, 'update' =>
'dynbookmark'));?>
</div>

This shows me on page load if this item is saved on "bookmark" list,
or not.
With the Ajax Link I can toogle this t save or to delete this item
from the bookmarks list.

But to display the correct link I need 3 important infos:
- the right picture
- link text ("add me" + "delete me")
- the controller action name (add / delete)

As far as I understand the ajax link stuff, I can return only a simple
string?
How could I create the entire link with all my needed information?

Any ideas or help?

Thanks!!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: