我试图在IFrame src中调用控制器动作,
$('#iframe').attr('src', 'controller/action');
如何在JavaScript函数中的上一行调用控制器动作?
<?php
echo CHtml::imageButton(Yii::app()->request->baseUrl.'/images/new.jpg'
,array('id'=>'reflist-button'
,'style'=>'display:inline-block',
'onclick'=>'$("#cru-frame-RefNew").attr("src","-----How to call controller action -------");
$("#RefList-New").dialog("open"); return false;'));?>
答案 0 :(得分:1)
试试这个
// save your url in a varible first
$myPath=Yii::app()->createUrl('controller/action');
然后更改此
'onclick'=>"$('#cru-frame-RefNew').attr('src',$myPath);
$('#RefList-New').dialog('open'); return false;"