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

  1. Rystraum wrote:

    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/

  2. alx wrote:

    make sure to use $this->params in stead of $this->data in your controller action

  3. Regz wrote:

    This helper is awesome... keep updating your helper...

  4. Ay Dot wrote:

    The editor isn't working. is it a conflict ?

  5. Denis wrote:

    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

  6. Denis wrote:

    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

  7. kvas wrote:

    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...

  8. Denis wrote:

    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

  9. kvas wrote:

    I think that you should use your own jQuery scripts. Helper is not designed for this kind of operations :(

  10. Denis wrote:

    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

  11. Denis wrote:

    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

  12. ryan wrote:

    it's missing the event 'onedit' when the mouse is clicked.

    You can add this to $this->editorOptions and options to string.

  13. ryan wrote:

    Actually, don't add to _optionsToString as it's not a function of the object ;)

  14. kvas wrote:

    Hi ryan,
    Actually 'onedit' event is not documented, so I don't know if it'll be suppod in new versions.

  15. james wrote:

    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.

  16. james wrote:

    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.

  17. alfadaemon wrote:

    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.

Post a comment

 

Additional options:

  • $options['var'] - name of variable that stores handler to editable method
 

jQuery Ajax Helper

CakePHP is distributed under flexible licence - MIT Licence. I decided to publish my code on the same licence, so you can freely use IT!

If I made you interested go and download it now!