We recently made the switch from the default Prototype + Scriptaculous required Ajax Helper CakePHP comes with to the jQuery version found here: http://blog.loadsys.com/2009/05/01/cakephp-jquery-ajax-helper-easy-scriptaculous-replacement/

This solved the conflict issues we ran into when needing Ajax/Prototype but also jQuery.

Just ran into one problem today though, I no longer was able to make Auto Updating Divs with remoteTimer function as that was left out from the new ajax helper.
With a little searching I found a jQuery addon: http://github.com/ncr/at_intervals/blob/master/jquery.at_intervals.js and then made my own remoteTimer function in the helper. Here is the first draft of it working for anyone who might have a similar situation.

function remoteTimer($id,$name=’foo’,$frequency=1000,$options = null) {
return $this->Javascript->codeBlock(”jQuery(’#{$id}’).at_intervals(function() {” . $this->remoteFunction($options) . “; return false;}, { name: ‘”.$name.”‘, delay: “.$frequency.” });”);
}

and an example from my view:

echo $ajax->remoteTimer(‘last_question_module’,'last_question_module’,5000,array(‘url’ => ‘/update_last_question/’.$this->data['Game']['id'],’update’ => ‘last_question_module’));

There is some redundancy that can be cleaned out but for now its working and I like it.


Subscribe to comments Comment | Trackback |
Post Tags:

Browse Timeline


Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>