js file not working in my partialrender view

Hi sorry i am new to yii framework and loving it so far but i ran into a bit of a issue

Firstly let me say i know this must of been asked before i have been searching all day for someone that solved the solutions but it seems no one has had my exact situation.

ok here goes

i have a normal landing page thats loads all my default css and js laying in assests/js and assest/css respectively

in my layout files here how things look




<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>

<?php Yii::app()->clientScript->registerScriptFile( Yii::app()->request->baseurl . '/assets/js/main.js' ); ?>



everything works great

so i have a view i am loading dynamically using jquery

it is in a controller named user the loading code looks as follows





class UserController extends Controller

{

	

	public function actionUregister()

	{

		$this->renderPartial('uregister');

	}




so in this view i am trying to render a js file located in assets/js named reg.js so in the view at the bottum this is what i am doing




<?php 

Yii::app()->clientScript->registerScriptFile(

        Yii::app()->baseUrl . '/assets/js/reg.js',

	CClientScript::POS_END

	);

?>



but for some or other strange reason it doesn’t seem to be rendering my new js file that i need for the operations need on the new view that i loaded using the above mentioned render partial

sorry for asking such a novice question but as i said i am very new to yiiframework any help will be greatly appreciated

Kind Regards

Snazz

Have you tried to comment out this line?


<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>

I once had the issue you describe when I registered jQuery explicitly in layouts/main.php, because Yii automatically loads jquery when necessary.

Edit: You may as well stick to CClientScript::POS_READY instead of CClientScript::POS_END.

Hi thanks for the fast reply

I tried what you suggested above and it unfortunately didnt fix things it killed jquery is there any config setting s that i need to set to make Yii automatically load jquery when necessary.

Sorry I overlooked the partial render.

Try with


$this->renderPartial('uregister', false, true);

More info: http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail

Thanks for the reply unfortunately i still didn’t render jquery automatically or include the new js for the view i am using a hack in the mean time but just including my reg.js file on my main layout and put it in a jquery.on() method to the it render on the dynamic documents so long

I am actually busy building a prototype of a port of my companies existing system running on zend framework to yiiframework so eventually i will have to make sure things like that are possible before they sign off on the deal but i am liking what i am experiencing on the yiiframework as a whole hoping to port some of my personal project over to yii as well as soon as i get all the normal swing of things working

Thanks for all your help i really appreciate it

Regards,

Snazz

Sorry let me sum up:

[list=1]

[*]Do not comment out the jQuery like I told you as first (ie forget about post #2)

[*]Set the processOutput parameter to true in your renderPartial call (post #4).

[/list]

Totally un-related to your post, but you might want to re-think the location of your files.

Generally the assets folder is used for cached files.

No reason at all why you can’t use it, but you may post a problem in the forum where a user will advise you to delete the contents of your assets folder (cache).

Just making you aware :)

Hi sorry for the late reply since i was a newbie i was only allowed three post on my first day and then i went on some much needed leave

I was just wondering if the is anything from a config level that i might of missed like in partial render do i need to register the script in my layout file of the main view i tried what you suggested but still wasn’t able to dynamic load view specific javascript files on the partial render of view i have gotten the green light base on the prototype i created but before i start porting the existing system i just need to make sure that its possible to load javascript dynamically like i need for partial render views so keep performance on top form

any help or pointers in the right direction will be much appreciated

Kind Regards,

Dean