Examples:
Complex options:
Dolor
<div class="edit" id="div_1">Dolor</div>
<?php
echo $ajax->editor(
"div_1",
array(
'controller' => 'ajax',
'action' => 'edit2',
),
array(
'indicator' => '<img src="/img/indicator.gif">',
'submit' => 'OK',
'style' => 'inherit',
'submitdata' => array('id'=> 2),
'tooltip' => 'Click to edit...'
)
);
?>
Select editor:
Edit me
<div class="edit" id="div_2">Edit me</div>
<?php
echo $ajax->editor(
"div_2",
array(
'controller' => 'ajax',
'action' => 'edit2',
),
array(
'indicator' => '<img src="/img/indicator.gif">',
'submit' => 'OK',
'type' => 'select',
'data' => array('Lorem ipsum'=>'Lorem ipsum','Ipsum dolor'=>'Ipsum dolor','Dolor sit'=>'Dolor sit'),
)
);
?>
Comments
Post a comment
Additional options:
- $options['var'] - name of variable that stores handler to editable method
2010-04-05 05:10:12
I made a sort-of tutorial on how to use the above editor, with the controller and view code.
http://rystraum.com/blog/2010/04/cakephp-and-ajax-inline-editing/
2010-04-05 13:55:58
make sure to use $this->params in stead of $this->data in your controller action
2010-04-16 09:09:12
This helper is awesome... keep updating your helper...
2010-11-15 18:52:07
The editor isn't working. is it a conflict ?
2010-11-25 20:34:14
hi,
does anyone see a problem with this code:
<div class="tblEntry" id="div_username" style="width: 30%; font-variant: normal;">
<?php echo $agent['User']['username'];
echo $ajax->editor("div_username",array(
'controller'=>'users',
'action'=>'edit',$user['User']['id']),
array(
'submit'=>'Accept',
'style'=>'inherit',
'submitdata'=>array('id'=>2),
'tooltip'=>'sdsg'));
?>
</div>
thanks in advance,
denis
2010-11-25 20:54:07
The above code is included in the main page through $ajax->link. Also included the jeditable js file but it still does not work.
Can anyone help?
thank you,
denis
2010-11-26 21:51:24
Hi Denis!
I think that the problem is that you loads editor by ajax request and the js handler are not triggered... Try to run editor on normal page and see if its work...
2010-11-29 10:43:36
hi kvas,
thank you for the suggestion..unfortunately my design of the website is to load the page through ajax in a certain <div>. Is there anyway around this issue?
thank you,
denis
2010-11-29 16:50:22
I think that you should use your own jQuery scripts. Helper is not designed for this kind of operations :(
2010-11-30 07:11:17
hi kvas,
I tested the script the way you mentioned and it still does not work. the view is loaded correctly but the editor still does not show up. any other ideas?
thank you,
denis
2010-11-30 08:22:37
Hi kvas,
updates on my problem: there is no problem with the helper or the script, it was a typeo on my part...
thanks for the help,
denis
2011-01-06 09:28:23
it's missing the event 'onedit' when the mouse is clicked.
You can add this to $this->editorOptions and options to string.
2011-01-06 09:32:33
Actually, don't add to _optionsToString as it's not a function of the object ;)
2011-01-06 12:30:35
Hi ryan,
Actually 'onedit' event is not documented, so I don't know if it'll be suppod in new versions.
2011-07-06 13:27:53
Thanks for the nice helper. I tried to update single field and it works but how can I update multiple fields?
If possible can you post the controller code also it will help me a lot.
2011-07-06 16:39:40
Thanks for the nice helper. I tried to update single field and it works but how can I update multiple fields?
If possible can you post the controller code also it will help me a lot.
2011-08-31 21:47:13
Hi Kvas, just one comment. I was having a lot of trouble getting this Ajax editor to work, and after some weeks I realize that the jquery.jeditable.js was needed!!.... please comment at the beginning of this that the plugin is required.