simple javascript problem

I’m trying to include a javascript file from a widget. Here’s the include code:




$cs=Yii::app()->getClientScript();

$cs->registerCoreScript('jquery');

$cs->registerScriptFile('/project/js/stjava.js');



stjava.js




<script type="text/javascript">

  $(function(){ alert("It's working!"); });

</script>



This should be simple, but I’m not sure why I get this message: “missing } in XML expression”

Is your js code without errors?Or the path is ok?

docs

If I moved the exact code I’m using into the layouts/main.php file and just stick it up in the head, it works fine. I mean, it’s the most basic hello world jquery script. When I go into the source, it shows up just fine, but firebug shows it as an error.

I used the example of docs I make a function registerClientScript()

and I call it at run() $this->registerClientScript()

and it worked

But I had $cs=Yii::app()->clientScript;




public function run()

{

        parent::run();

	$this->registerClientScript();

}

	

public function registerClientScript()

{

	$cs=Yii::app()->getClientScript();

	$cs->registerCoreScript('jquery');

	$cs->registerScriptFile('/project/js/stjava.js');

}



Still is giving me the bogus javascript error. It’s probably something stupid, but idk.

Can you see the plain html of you page?

stjava.js must be




 $(function(){ alert("It's working!"); });



without script tag

Yeah, without script tag is the answer. I knew it was something silly. Thanks, buddy.