I am using Laravel 4
How can I add a link to a image inside a .css or .js file.
If I put a relative path like that:
background-image: url("../assets/images/assets.png");
it will load the file only if my view is like that
/mysite/users
if the url of my view change from
/mysite/users
to
/mysite/users/job/10/something
It will not load.
I can put the full path like that:
background-image: url("/mysite/assets/images/assets.png");
but if I have to create a copy of this site like 'theSite', I will have to open All my css files and .js file and replace /mysite to /theSite
Are there a smarty way to do that? like I use in the view:
{{ URL::to('style.css') }}
.
EDITED
The ceejayoz is correct.
But if you need a .js file that call a Controller you could do this:
create this route:
Route::get('/js/custom.js ', function()
{
$contents = View::make('js/custom');
$response = Response::make($contents, 200);
$response->header('Content-Type', 'application/javascript');
return $response;
});
create the custom.blade.php view and put this js content:
$('#inputX').change(function() {
$.ajax({
url: "{{URL::to('track/data')}}",
type: "GET",
cache: false,
async: sync,
data: {
doit: $('#inputX').val()
},
success: function(data)
{
console.log(data)
}
});
});
What do you think about it?