How to pass a VueJS variable into a Laravel blade routeHow to place vue variable inside a laravel bracketReference - What does this error mean in PHP?How to Set Variables in a Laravel Blade TemplateHow to pass variables and data from PHP to JavaScript?Laravel navigation bar not working after using a route with $id parameter?laravel blade template variablesLaravel / Blade - is it possible to echo a variable into the parameter of a function?How to loop records through textfield valueLaravel blade, recursive view with php translated to bladeUsing JavaScript variables inside laravel blade routesSearch in vuejs with laravel backend api
C++ check if statement can be evaluated constexpr
Why do ¬, ∀ and ∃ have the same precedence?
How to make money from a browser who sees 5 seconds into the future of any web page?
Why do Radio Buttons not fill the entire outer circle?
When were female captains banned from Starfleet?
What kind of floor tile is this?
Why is so much work done on numerical verification of the Riemann Hypothesis?
How can I write humor as character trait?
What does Apple's new App Store requirement mean
Is there a RAID 0 Equivalent for RAM?
Does Doodling or Improvising on the Piano Have Any Benefits?
Taxes on Dividends in a Roth IRA
Stack Interview Code methods made from class Node and Smart Pointers
C++ copy constructor called at return
Change the color of a single dot in `ddot` symbol
Does "he squandered his car on drink" sound natural?
Do we have to expect a queue for the shuttle from Watford Junction to Harry Potter Studio?
Creating two special characters
Is it allowed to activate the ability of multiple planeswalkers in a single turn?
How much of a Devil Fruit must be consumed to gain the power?
A variation to the phrase "hanging over my shoulders"
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Is this part of the description of the Archfey warlock's Misty Escape feature redundant?
Has any country ever had 2 former presidents in jail simultaneously?
How to pass a VueJS variable into a Laravel blade route
How to place vue variable inside a laravel bracketReference - What does this error mean in PHP?How to Set Variables in a Laravel Blade TemplateHow to pass variables and data from PHP to JavaScript?Laravel navigation bar not working after using a route with $id parameter?laravel blade template variablesLaravel / Blade - is it possible to echo a variable into the parameter of a function?How to loop records through textfield valueLaravel blade, recursive view with php translated to bladeUsing JavaScript variables inside laravel blade routesSearch in vuejs with laravel backend api
I'm looping over a JSON array in VueJS and outputting each item to the screen but I need to create a link/route to a resource controller with the ID being returned for each row like so:
<tr v-for="item in searchResults.group">
<td>
<a href=" route('admin.edit', @ item.id ) "><button type="button" class="btn btn-info btn-sm">Edit</button></a>
So I've tried putting the variable into the route like so @ item.id
but get the error:
syntax error, unexpected '{' (View: /application/resources/views/admin/edit.blade.php)
The way I have done it is not the correct way obviously but I can't find anything in the documentation to achieve this.
EDIT:
Further input on this. The route function requires a second parameter, in this case, the ID of the item to edit. In pure PHP/Blade I have this and it works:
<a href=" route('admin.edit', $item->id ) "><button type="button" class="btn btn-info btn-sm">Reduce</button></a>
For the dynamic search page, I need to somehow pass that second parameter into blade/php from a vuejs variable but I just can't work out how to do it.
php laravel vue.js
add a comment |
I'm looping over a JSON array in VueJS and outputting each item to the screen but I need to create a link/route to a resource controller with the ID being returned for each row like so:
<tr v-for="item in searchResults.group">
<td>
<a href=" route('admin.edit', @ item.id ) "><button type="button" class="btn btn-info btn-sm">Edit</button></a>
So I've tried putting the variable into the route like so @ item.id
but get the error:
syntax error, unexpected '{' (View: /application/resources/views/admin/edit.blade.php)
The way I have done it is not the correct way obviously but I can't find anything in the documentation to achieve this.
EDIT:
Further input on this. The route function requires a second parameter, in this case, the ID of the item to edit. In pure PHP/Blade I have this and it works:
<a href=" route('admin.edit', $item->id ) "><button type="button" class="btn btn-info btn-sm">Reduce</button></a>
For the dynamic search page, I need to somehow pass that second parameter into blade/php from a vuejs variable but I just can't work out how to do it.
php laravel vue.js
Can you show route defined in web file?
– Saad Suri
13 hours ago
Possible duplicate of How to place vue variable inside a laravel bracket
– Emīls Gulbis
13 hours ago
add a comment |
I'm looping over a JSON array in VueJS and outputting each item to the screen but I need to create a link/route to a resource controller with the ID being returned for each row like so:
<tr v-for="item in searchResults.group">
<td>
<a href=" route('admin.edit', @ item.id ) "><button type="button" class="btn btn-info btn-sm">Edit</button></a>
So I've tried putting the variable into the route like so @ item.id
but get the error:
syntax error, unexpected '{' (View: /application/resources/views/admin/edit.blade.php)
The way I have done it is not the correct way obviously but I can't find anything in the documentation to achieve this.
EDIT:
Further input on this. The route function requires a second parameter, in this case, the ID of the item to edit. In pure PHP/Blade I have this and it works:
<a href=" route('admin.edit', $item->id ) "><button type="button" class="btn btn-info btn-sm">Reduce</button></a>
For the dynamic search page, I need to somehow pass that second parameter into blade/php from a vuejs variable but I just can't work out how to do it.
php laravel vue.js
I'm looping over a JSON array in VueJS and outputting each item to the screen but I need to create a link/route to a resource controller with the ID being returned for each row like so:
<tr v-for="item in searchResults.group">
<td>
<a href=" route('admin.edit', @ item.id ) "><button type="button" class="btn btn-info btn-sm">Edit</button></a>
So I've tried putting the variable into the route like so @ item.id
but get the error:
syntax error, unexpected '{' (View: /application/resources/views/admin/edit.blade.php)
The way I have done it is not the correct way obviously but I can't find anything in the documentation to achieve this.
EDIT:
Further input on this. The route function requires a second parameter, in this case, the ID of the item to edit. In pure PHP/Blade I have this and it works:
<a href=" route('admin.edit', $item->id ) "><button type="button" class="btn btn-info btn-sm">Reduce</button></a>
For the dynamic search page, I need to somehow pass that second parameter into blade/php from a vuejs variable but I just can't work out how to do it.
php laravel vue.js
php laravel vue.js
edited 13 hours ago
twigg
asked 13 hours ago
twiggtwigg
1,28552961
1,28552961
Can you show route defined in web file?
– Saad Suri
13 hours ago
Possible duplicate of How to place vue variable inside a laravel bracket
– Emīls Gulbis
13 hours ago
add a comment |
Can you show route defined in web file?
– Saad Suri
13 hours ago
Possible duplicate of How to place vue variable inside a laravel bracket
– Emīls Gulbis
13 hours ago
Can you show route defined in web file?
– Saad Suri
13 hours ago
Can you show route defined in web file?
– Saad Suri
13 hours ago
Possible duplicate of How to place vue variable inside a laravel bracket
– Emīls Gulbis
13 hours ago
Possible duplicate of How to place vue variable inside a laravel bracket
– Emīls Gulbis
13 hours ago
add a comment |
3 Answers
3
active
oldest
votes
You can try by appending the id to the end like so:
route('admin.edit') /@ item.id
I'm guessing you are following a REST URI guides so that would work for you.
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
1
@twigg What you could do was to define the routeadmin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer
– The dude
12 hours ago
add a comment |
Use Like this
<a href=" route('admin.edit') ?course_id=@ item.id ">Click</a>
New contributor
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
add a comment |
You are mixing two concepts that won't go together like this.
The blade template is rendered server-side, whereas the parts of your vue.js related markup will be parsed on the client side (e.g. "browser").
Because of that, referencing a property of item
within a blade expression will fail (as it does).
<a href=" route('admin.edit', @ item.id ) "
route(...)
refers to an expression that is related to blade, an item
is supposed to be a part of your vue.js app.
What you need to do is to dynamically create the link for editing the ressource within your vue.js app once you loop your searchResult.group
.
You could achieve this by injecting a "route-template" for editing the ressource into your vue.js app and bind the href property to a vue.js method, like this:
<tr v-for="item in searchResults.group">
<a v-bind:href="getEditLink(item.id)">Edit</a>
....
The according method getEditLink(id)
then assembles the actual link based on the given id of item
and the provided "route"-template.
New contributor
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280055%2fhow-to-pass-a-vuejs-variable-into-a-laravel-blade-route%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try by appending the id to the end like so:
route('admin.edit') /@ item.id
I'm guessing you are following a REST URI guides so that would work for you.
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
1
@twigg What you could do was to define the routeadmin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer
– The dude
12 hours ago
add a comment |
You can try by appending the id to the end like so:
route('admin.edit') /@ item.id
I'm guessing you are following a REST URI guides so that would work for you.
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
1
@twigg What you could do was to define the routeadmin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer
– The dude
12 hours ago
add a comment |
You can try by appending the id to the end like so:
route('admin.edit') /@ item.id
I'm guessing you are following a REST URI guides so that would work for you.
You can try by appending the id to the end like so:
route('admin.edit') /@ item.id
I'm guessing you are following a REST URI guides so that would work for you.
answered 13 hours ago
The dudeThe dude
4831616
4831616
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
1
@twigg What you could do was to define the routeadmin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer
– The dude
12 hours ago
add a comment |
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
1
@twigg What you could do was to define the routeadmin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer
– The dude
12 hours ago
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)
Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case)
Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
1
1
@twigg What you could do was to define the route
admin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer– The dude
12 hours ago
@twigg What you could do was to define the route
admin.edit
s parameter optional and then use the method I suggested in my answer. Not the best option but it's the only answer I'm seeing now. Let me know if you need more clarification and I can edit my answer– The dude
12 hours ago
add a comment |
Use Like this
<a href=" route('admin.edit') ?course_id=@ item.id ">Click</a>
New contributor
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
add a comment |
Use Like this
<a href=" route('admin.edit') ?course_id=@ item.id ">Click</a>
New contributor
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
add a comment |
Use Like this
<a href=" route('admin.edit') ?course_id=@ item.id ">Click</a>
New contributor
Use Like this
<a href=" route('admin.edit') ?course_id=@ item.id ">Click</a>
New contributor
edited 13 hours ago
New contributor
answered 13 hours ago
Future CoderFuture Coder
1465
1465
New contributor
New contributor
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
add a comment |
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
Hey thanks for the input, this doesn't work I tried something similar, it fails because route is expecting a second parameter (the id in this case) Missing required parameters for [Route: admin.edit] [URI: admin/edit/id]
– twigg
13 hours ago
add a comment |
You are mixing two concepts that won't go together like this.
The blade template is rendered server-side, whereas the parts of your vue.js related markup will be parsed on the client side (e.g. "browser").
Because of that, referencing a property of item
within a blade expression will fail (as it does).
<a href=" route('admin.edit', @ item.id ) "
route(...)
refers to an expression that is related to blade, an item
is supposed to be a part of your vue.js app.
What you need to do is to dynamically create the link for editing the ressource within your vue.js app once you loop your searchResult.group
.
You could achieve this by injecting a "route-template" for editing the ressource into your vue.js app and bind the href property to a vue.js method, like this:
<tr v-for="item in searchResults.group">
<a v-bind:href="getEditLink(item.id)">Edit</a>
....
The according method getEditLink(id)
then assembles the actual link based on the given id of item
and the provided "route"-template.
New contributor
add a comment |
You are mixing two concepts that won't go together like this.
The blade template is rendered server-side, whereas the parts of your vue.js related markup will be parsed on the client side (e.g. "browser").
Because of that, referencing a property of item
within a blade expression will fail (as it does).
<a href=" route('admin.edit', @ item.id ) "
route(...)
refers to an expression that is related to blade, an item
is supposed to be a part of your vue.js app.
What you need to do is to dynamically create the link for editing the ressource within your vue.js app once you loop your searchResult.group
.
You could achieve this by injecting a "route-template" for editing the ressource into your vue.js app and bind the href property to a vue.js method, like this:
<tr v-for="item in searchResults.group">
<a v-bind:href="getEditLink(item.id)">Edit</a>
....
The according method getEditLink(id)
then assembles the actual link based on the given id of item
and the provided "route"-template.
New contributor
add a comment |
You are mixing two concepts that won't go together like this.
The blade template is rendered server-side, whereas the parts of your vue.js related markup will be parsed on the client side (e.g. "browser").
Because of that, referencing a property of item
within a blade expression will fail (as it does).
<a href=" route('admin.edit', @ item.id ) "
route(...)
refers to an expression that is related to blade, an item
is supposed to be a part of your vue.js app.
What you need to do is to dynamically create the link for editing the ressource within your vue.js app once you loop your searchResult.group
.
You could achieve this by injecting a "route-template" for editing the ressource into your vue.js app and bind the href property to a vue.js method, like this:
<tr v-for="item in searchResults.group">
<a v-bind:href="getEditLink(item.id)">Edit</a>
....
The according method getEditLink(id)
then assembles the actual link based on the given id of item
and the provided "route"-template.
New contributor
You are mixing two concepts that won't go together like this.
The blade template is rendered server-side, whereas the parts of your vue.js related markup will be parsed on the client side (e.g. "browser").
Because of that, referencing a property of item
within a blade expression will fail (as it does).
<a href=" route('admin.edit', @ item.id ) "
route(...)
refers to an expression that is related to blade, an item
is supposed to be a part of your vue.js app.
What you need to do is to dynamically create the link for editing the ressource within your vue.js app once you loop your searchResult.group
.
You could achieve this by injecting a "route-template" for editing the ressource into your vue.js app and bind the href property to a vue.js method, like this:
<tr v-for="item in searchResults.group">
<a v-bind:href="getEditLink(item.id)">Edit</a>
....
The according method getEditLink(id)
then assembles the actual link based on the given id of item
and the provided "route"-template.
New contributor
New contributor
answered 11 hours ago
myndmynd
1164
1164
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55280055%2fhow-to-pass-a-vuejs-variable-into-a-laravel-blade-route%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you show route defined in web file?
– Saad Suri
13 hours ago
Possible duplicate of How to place vue variable inside a laravel bracket
– Emīls Gulbis
13 hours ago