php - Write the values of the ajaxoptions array dynamically using Yii -
i'm calling chtml::ajaxlink
so:
<?php echo chtml::ajaxlink('add list', $this->createurl('itemlist/ajaxadditem'), array( 'onclick'=>'$("#addtolistdialog").dialog("open"); return false;', 'type'=>'post', 'update'=>'#addtolistdialog', 'data' => 'js:{"product_id" : $("#productid").val()}' ), array('id'=>'showaddtolistdialog')); ?>
i don't know how write values of ajax options array dynamically. i'm using workaround value using javascript, $("#productid").val()
, hidden field.
i want write like:
'data' => 'js:{"product_id" : "$model->product_id"}'
but "$model->product_id"
entered literal string.
can give me way this? method won't solve problem since need write ajax link multiple times on fly.
assuming $model instance available, should able append dynamically below: 'data' => "js:{'product_id' : '{$model->product_id}'}"
Comments
Post a Comment