views:

39

answers:

2

hi to all i am using cakephp in my project. in this at one section i need to update the particular row onclick of the image. using ajax. i used mootools as javascript library. so please help me how could i do this.

thanks in advance

A: 

As i know most programmer work with protype.js library.

i am giving you link see

go to there

Sanjay
+1  A: 

Simply speaking:

  1. Create a CakePHP controller action that performs the row update.
  2. Determine the URL of the controller action you just created. (ie. /controllername/actionname)
  3. Determine if you need to do a GET or POST request to this URL for it to work.
  4. Put code in your view that attaches an "onclick" event that makes and AJAX (GET/POST) request to the above controller.

CakePHP has a javascript helper that traditionally produced Prototype code, but in v1.3 it is now able to produce code for other Javascript frameworks (such as Mootools, jQuery, etc.)

However, many suggest writing your javascript in javascript (eg. actually using the Mootools framwork), rather than writing your javascript in PHP (like using CakePHP's helper to produce Mootools code).

Either way, in your view you need to have something like: <?php echo $js->link(.. or <script>Moo.. or <a onclick="Moo.. to attach your Javascript to that link.

You may also wish for your controller action to return some sort of response indicating whether or not the row update failed or succeeded. In that case you need to make sure the CakePHP controller action you are calling has a view that outputs this. JSON seems to be the ideal format for this (eg. { success: true }), but you need to remember to turn off Cake's debug output. This response can be captured into a variable by your Mootools code where you can decide what to do with it (eg. displaying an error).

deizel