Hi there,
Here is the scenario, please help.
When I click the button, it will send an ajax request, then fill in the content into a div. As you can see below the codes, i use renderPartical to render the view, and the rendered view contains a js code, which is ‘alert();’, but I can only see the ‘text…’.I also expect to see the ‘alert(‘yeah!’)’, but it does no appear. Please what’s the problem?
view:
<button id="btn">
<div id="panel"></div>
.....
$('#btn').on('click', function(){
...
url: 'xx/fetchTheView',
success: function(html) {
$('#panel').html(html);
}
})
controller:
public function actionFetchTheView() {
renderPartial('_view', array('text'=>'this is the text'), false, true);
}
_view.php
<?php
echo $text;
Yii::app()->clientScript->registerScript('js_js', "
alert('yeah!');
...
");