I'm using Laravel and I have a blade with the variable:
{{$project->slug}}
On the blade I also have a button with which I want to open a new window, but as I have different projects it has to be 'dynamic'.
The code of the button is as follows:
<button type="button" class="btn btn-default btn-sm on buttonpreview" target="_blank" id="urlproyecto">
<span class="glyphicon glyphicon-eye-open"></span>Ver Proyecto
</button>
The JS code is as follows:
$("#urlproyecto").click(function(){
window.open('http://'+window.location.hostname+'/es/works/')
})
In the JS code you should add, at the end of the URL, the variable {{$project->slug}}
What would be the most efficient way to do it?