alpine js and edge js

hello guys , sorry if this is a stupid question but i have been searching for way to pass data from alpine js to edge js , in my case i need to pass an id to the route() where the id is coming from the selectedReview alpine variable :

<template x-if="selectedReview" >

<form action="{{route('reviews.update',{id:"**i need the id here** "})}}" i thought i could use the x-bind but it didn't work for me

Join The Discussion! (1 Replies)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 17 days ago

    This was answered on Discord, but I'll go ahead and answer here in case others come across it wondering the same.

    EdgeJS renders HTML markup on your AdonisJS server while AlpineJS mutates the markup in the browser. Once the markup reaches the browser, EdgeJS has already done its job and is out of the picture, so what is being asked isn't possible.

    Instead you'll need to use a client-side solution, like Tuyau, if you want to generate routes. Or, you can just hard code the route and use AlpineJS to populate the id that way.

    <form :action="`/reviews/update/${selectedReview}`">
    </form>
    Copied!
    0

    Please sign in or sign up for free to reply