Wizard
Wizard

Reputation: 11275

Yii javascript on page

In my web-page my Javascript code looks like:

$js1 = <<< JS
 function test1() {
 }   
JS;

$js2 = <<< JS
 function test2() {
 }   
JS;

$j3 = <<< JS
 function test3() {
 }   
JS;

Using some kind of logic I want to concatenate Javascript like this:

if ($something == 1 ){
    $js = $js1.$js2;
} 

How can I do that properly with Yii rules?

Upvotes: 0

Views: 39

Answers (1)

Nahian Khondoker
Nahian Khondoker

Reputation: 367

once you have the cocatenated $js, simply do...

<?php Yii::app()->clientScript->registerScript('myJS', $js); ?>

Upvotes: 1

Related Questions