Hello…
I have following problem and I don’t know how to solve it.
I have table with lots of rows that can be dynamically added/removed by jQuery. It works. But on each row of this table there are 2 drop-down-lists. If I choose something in the first one, the second one should be refreshed and filled with new values using ajax. Typical task. But it does not work as I want.
Because all rows have the same structure I created a function that creates code for a new row. This function is in controller. If I use it, Yii does not generate jQuery code and my ajax does not work.
If I try to define one set of drop-down-lists manually in the view, it works well.
I wanted not to use the Yii’s ajax and to write it by my self. It is easier than the Yii’s way, but it does not work neither. I did it like this:
echo CHtml::dropDownList(
'name',
'',
array(1=>'val1',2=>'val2'),
array('onChange'=>'$.post(\''.Yii::app()->request->baseUrl.'/controller/action\');')
);
this produces following HTML code:
select id="name" name="name" onchange="$.post('/mysite/controller/action');">
And when I select a value in the drop-down-list I only get CHTML error 400 = bad request?
The post() function does not work.
Im not able to describe my problem better, it is very complacated … I hope someone has solved a similar problem…