I have a javascript function like this :
function addRow(){
$('#mainbody').append('<tr>' +
'<td><select class="form-control" name="addmore['+i+'][name]" id="name'+i+'" required >' +
'<option disabled="disabled" selected="selected" value="" >Select Product</option>' +
'@foreach($produk as $pro)' +
'<option value="{{$pro->id}}">{{$pro->nama}}</option>' +
'@endforeach'
)}
When I use the script in the same blade (view) file, it work, but when I separate the javascript function, and included the script on header, it show the blade syntax literally like {{ $pro->id }} (not the actual number from controller, but it does append a new row with {{ $pro->name }} as the value).
So my question is, can I make a separate file for my javascript function ? Because I'm using the script in create and edit view, so I want to make my view more cleaner.