2011-02-24 81 views
3

我在我的网站设计了一个3级菜单,我使用yii作为php框架。yii多级ajaxLink

例如:

 
ItemA 
Item_a1 
    Item_a11 
    Item_a12 
Item_a2 
ItemB 
... 

对于一些原因,我想使用Ajax来生成这些分项目。

因此,我写了CHtml :: ajaxLink(“ItemA”,url,...);它可以很好地生成第二级项目,即Item_a1,Item_a2,...

我的问题是当我使用CHtml :: ajaxLink(“Item_a1”,url,...);到ajax生成第三级,它不能工作。

我的猜测是,当我第二次通过renderPartial生成ajaxLink时,yii没有在视图中注入相应的js脚本,因此链接无法工作。

我不知道如何解决这个问题,请帮忙!谢谢!

回答

2

你很可能是正确的,并且renderPartial()上有一个参数,它将强制包含JS代码来解决这个问题。类似这样的:

$this->renderPartial(
    '_partialview', // your menu view 
    array(), // data/variables for your view 
    false, // whether it should print or return the buffered output 
    true, // "processOutput" - false by default, this should output your JS now 
); 

祝你好运!

+0

哦,我忘了renderPartial的第四个参数!谢谢! – 2011-02-24 23:47:18

+0

然后工作?很高兴听到!干杯 – thaddeusmt 2011-02-25 02:23:59