I'm trying to inject a javascript variable inside php curly braces code, but I am no t able to get it working.
This is the code that I have inside a php.blade javascript function:
swal(...),
success(data){
$('#especie').select2("trigger", "select", {
data: {
id: data.id_especie,
text: "(" + data.especie.id + ") " + data.especie.nombre,
html: "{{ view('especies.select', [ 'especie' => data.especie])->render() }}"
},
templateResult: iconosTemplate,
templateSelection: iconosTemplate
});
}
Inside html: {{ view('especies.select', [ 'especie' => data.especie])->render() }}
I want the data
variable to be the swal success data, but it is not taking it as it's inside php context.