Is This Behaviour Expected?

Hi!

I’m publishing module’s assets (js+images+css) with:


$url = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.modules.imo.assets'),false,-1,YII_DEBUG);

Registering js script:


Yii::app()->clientScript->registerScriptFile($url.'/js/script.js');

Everything is published correctly, the browser requests the script in folder base/assets/xxxxxxx/js/, but inside the script, when I try to set an image source path, with something like …/images/image.png I always get the base folder not the assets one… document.url returns the base folder too…

Here is the script:


var imgs = {

1: '../images/img1.png',

2: '../images/img2.png',

3: '../images/img3.png'

};


$.getJSON('list/get', updateIms);

	

function updateIms(data) {


	$.each(data, function (i, item) {


		var listitem = 

				"<div class='imlistitem'>" +

					"<div class='imlistitemtipo'>" +

						"<img src='" + imgs[item.tipo] + "'/>" +

					"</div>" +

				"</div>";

	

		$(imlist).append($(listitem));

		

		

	});

		

}

I got an workaround but I don’t like it, in the script I get the path with:


var scripts = document.getElementsByTagName("script");

var path = scripts[scripts.length-1].src;

And then I construct the image path string accordingly.

Thanks