1

I'm just upgrading some code from cakephp 1.1 to 2.2.3 and I'm stuck on the ajax bits. The forms are completely different but they've I've reworked them just fine.

When I view the source I get this from the echo $this->Js->writeBuffer(); command

//<![CDATA[
$j(document).ready(function () {$("#AdlistingRegion").bind("click", function (event)     {$.ajax({async:true, dataType:"html", success:function (data, textStatus) {$("#AdlistingDistrict").html(data);}, url:"\/adlistings\/getdistricts"});
return false;});
$("#AdlistingDistrict").bind("click", function (event) {$.ajax({async:true, dataType:"html", success:function (data, textStatus) {$("#AdlistingSuburb").html(data);}, url:"\/adlistings\/getsuburbs"});
return false;});});
//]]>

however firebug tells me

Uncaught TypeError: Property '$' of object [object Window] is not a function 

This appears to be a flaw in the library which doesn't seem plausible but I've got the JS helper in the controller and can't see which step I've missed.

Does anyone have any ideas?

4

1 回答 1

0

这是一个小技巧,但对我有用;)

<?php echo str_replace('$(document).ready(function ()', 'jQuery(document).ready(function($)',  $this->Js->writeBuffer()); ?>

阅读有关安全 jQuery 的更多信息:http: //api.jquery.com/jQuery.noConflict/

于 2013-07-23T11:08:10.940 回答