Reputation: 635
I'm designing a 3-level menu in my website, and I use yii as the php-framework.
For example:
ItemA Item_a1 Item_a11 Item_a12 Item_a2 ItemB ...
For some reasons I'd like to use ajax to generate those sub_items.
Therefore I wrote CHtml::ajaxLink("ItemA", url, ...); and it works fine to generate the second level items, i.e Item_a1, Item_a2, ....
My problem is the when I use CHtml::ajaxLink("Item_a1", url, ...); to ajax to generate the 3rd level, it can't work.
My guess is that when the second time I generate the ajaxLink by renderPartial, yii didn't inject the corresponding js-script to the view so that the link can't work.
I don't know how to fix this problem, please help! Thanks!
Upvotes: 3
Views: 1189
Reputation: 15600
You are most likely right, and there is a parameter on renderPartial() which will force including the JS code to fix this. Something like this:
$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
);
Good luck!
Upvotes: 2