Re: jQuery sortable: how to update database?
Indeed Euromark, that was the reason it didn't work. I changed the notation too so I have an up-to-date program running;) Salines & Euromark: thank you for helping me with this issue, I *realy*appreciate this! I can go further exploring CakePHP now! :) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: jQuery sortable: how to update database?
you forgot the () after the method names $this->RequestHandler->isAjax() etc also, this is deprecated, use $this->request->is('ajax') etc as documeted Am Sonntag, 2. Februar 2014 12:16:02 UTC+1 schrieb Sam Clauw: > > Allright, that will be much easier to understand the whole AJAX and > request happening! Last years, I've realy struggled with this and I think > it will be a lot clearer for me now. Thank you! > To go back on my sorting problem: it isn't working yet. I dugged into > CakePHP's Request Handling documentation and tried to catch the POST values > from that AJAX request. The strange thing is that my controller seems to > haven't catched a request at all! Here's my controller code: > > class AttractionsController extends CoasterCmsAppController > { > public $components = array( > 'RequestHandler' > ); > ... > public function beforeFilter() { > if ($this->RequestHandler->isAjax) { > echo 'Ajax'; > } elseif ($this->RequestHandler->isPost) { > echo 'Post'; > } elseif ($this->RequestHandler->isGet) { > echo 'Get'; > } else { > echo 'Damn, this string shouldn't be here!'; > } > } > } > > As you can guess, I always got the string "Damn, this string shouldn't be > here!" outputted (instead of the "Ajax" echo). However, my javascript has > no errors and I do get my data when I alert it in the "succeed" of my > $.ajax. Is there something crucial that I'm forgetting? :) > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: jQuery sortable: how to update database?
Allright, that will be much easier to understand the whole AJAX and request happening! Last years, I've realy struggled with this and I think it will be a lot clearer for me now. Thank you! To go back on my sorting problem: it isn't working yet. I dugged into CakePHP's Request Handling documentation and tried to catch the POST values from that AJAX request. The strange thing is that my controller seems to haven't catched a request at all! Here's my controller code: class AttractionsController extends CoasterCmsAppController { public $components = array( 'RequestHandler' ); ... public function beforeFilter() { if ($this->RequestHandler->isAjax) { echo 'Ajax'; } elseif ($this->RequestHandler->isPost) { echo 'Post'; } elseif ($this->RequestHandler->isGet) { echo 'Get'; } else { echo 'Damn, this string shouldn't be here!'; } } } As you can guess, I always got the string "Damn, this string shouldn't be here!" outputted (instead of the "Ajax" echo). However, my javascript has no errors and I do get my data when I alert it in the "succeed" of my $.ajax. Is there something crucial that I'm forgetting? :) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: jQuery sortable: how to update database?
*One additional thing: where in Chrome developer tools can you see those ajax values? Elements, Network, Sources, ...? ;)* Open CDT and select the Network tab, then sort the table and view the query output in the Network tab. Select an output request for more details ;) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: jQuery sortable: how to update database?
Ow yes, you've got me on the right way! I've changed my .ctp file now: $(function() { $('.sortable tbody').sortable({ axis: 'y', scroll: true, opacity: 0.5, revert: 100, cursor: 's-resize', items: 'tr.grab', // volledige breedte vanbehouden helper: function (e, ui) { ui.children().each(function () { $(this).width($(this).width()); }); return ui; }, stop: function (event, ui) { var data = $(this).sortable('serialize'); // POST naar server ($.post of $.ajax) $.ajax({ data: data, type: 'POST', url: '*here; ?>*' }); } }).disableSelection(); }); Then, I'll check on a submitted POST in my sort action and will handle the update. One additional thing: where in Chrome developer tools can you see those ajax values? Elements, Network, Sources, ...? ;) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: jQuery sortable: how to update database?
You do it in the wrong way. In your controller create method and then put the code that will save your changes. use chrome developer tools or firefox firebug to see which values are sent via ajax query -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.