Larry Garfield wrote:
> Well it helped me. :-) On topic, I vaguely recall something about
> CakePHP playing nice with jQuery instead of Prototype, but Googling
> didn't turn up anything. Do you use jQuery with cake, and if so how?
> Any suggested resources for that?
I'm currently using jQuery with CakePHP with no problems.
The CakePHP's own ajax-helpers use the prototype library. However, since
making ajax calls with jQuery is so easy I've recently dropped using the
built-in ajax helpers completely, and do everything with jQuery instead. If
you don't include the prototype library at all in the layout, jQuery works
as well as anywhere.
If you want to keep using both (which I did for some time), you can
accomplish this by binding another alias to jQuery instead of "$". This is
easy, just first include the jQuery library, rebind, then include the
prototype library, like this:
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
JQ = $;
</script>
<script type="text/javascript" src="prototype.js"></script>
The use jQuery as normal, just always replace "$" with "JQ":
JQ('#mydiv').show("fast");
If you use plugins, you should do a find-and-replace in the plugin source,
replacing all "$" with "JQ" to make those work too. This should not be
necessary, since plugin devs are encouraged not to use the $-shortcut inside
plugin code, just for this reason, but some plugins still do.
If you want to go further, you can always make your own CakePHP helpers (or
tune the existing ones) to use jQuery. Making helpers in CakePHP is pretty
straightforward. See the manual section about helpers at:
http://manual.cakephp.org/chapter/helpers (Section 2. is about making your
own).
I think we could try to push the CakePHP devs into thinking about moving on
to (or adding support for) jQuery out-of-the-box, but that might take a
while. There seem to be several active CakePHP users here though. A group
effort might actually get noticed.
--
Suni
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/