Correct path for images in javascript using Cakephp -
i new in cakephp, , have script, converted cakephp. have there rotate background use 4 images this:
$.backstretch([ "img/bg/1.jpg", "img/bg/2.jpg", "img/bg/3.jpg", "img/bg/4.jpg" ], { fade: 1000, duration: 8000 });
when open script name_domain.com use controller users , action login, see images , work perfect, when try use register (controller=>users, action=>signup)
images not load. put ../img....
working here , not in index.
how can link correctly images. try "/img" not working.
any appreciated.
declare javascript variable in default.ctp
var image_host = "<?php echo $this->webroot.'/img/'; ?>";
and can use in javascript file too
<script> $.backstretch([ image_host + "bg/1.jpg", image_host + "bg/2.jpg", image_host + "bg/3.jpg", image_host + "bg/4.jpg" ], { fade: 1000, duration: 8000 });
hope helps..!!
Comments
Post a Comment