Reputation: 3
ROUTE:
Route::get('usuario/{id}/edit', ['as' => 'users.edit', 'uses' => 'Admin\UserController@edit']);
if it brings me the right id (data.id):
<a href="users.edit/' + data.id + '" class="btn btn-xs btn-primary" ><i class="glyphicon glyphicon-edit"></i></a>
it does not bring me the right id:
<a href="{{ route('users.edit','+data.id+') }}" class="btn btn-xs btn-primary" ><i class="glyphicon glyphicon-edit"></i></a>
How to add inside Laravel (Blade engine?) Concatenation doesn't work
CODE: {data: null, render: function (data, type, row) { return ''; //return ''; } }
Upvotes: 0
Views: 79
Reputation: 50798
The problem is that you're literally passing: +data.id+
as your argument. Because PHP cannot be interpreted on the client side, you can only alias it ahead of time and modify it later:
let route = '{{ route('users.edit', '%DATA_ID%') }}'
Add a class to the anchor link for reference:
<a class="btn btn-xs btn-primary edit-link"...
Then select it and update the route later:
document.querySelector('a.edit-link').href = route.replace('%DATA_ID%', data.id)
Or if you've got $data
as an stdClass coming back from Laravel:
<a href="{{ route('users.edit', $data->id) }}" class="btn btn-xs btn-primary">
Upvotes: 1