tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.91k stars 248 forks source link

Issue with route() not taking me to a named route, and instead trying to set the url to just whats typed. #569

Closed Adzeiros closed 2 years ago

Adzeiros commented 2 years ago

Ziggy version

1.4.6

Laravel version

9.17.0

Description

I am using Laravel Breeze Inertia Vue.

In my Vue page I am attempting to call on onclick event that changes the route, however using route('forms.show', form.id) just does absolutely nothing, no console output and the route does not change.

I have tried entering the URL manually, however, it just says that the route doesn't exist.

Ziggy call and context

<div v-on:click="route('forms.show', form.id)"></div>

Ziggy configuration

routes: {
forms: {uri: 'forms', methods: Array(2)}
forms.show:
methods: (2) ['GET', 'HEAD']
uri: "forms/{id}"
}

Route definition

Route::get('/forms/{id}', [FormsController::class, 'show'])->middleware(['auth', 'verified'])->name('forms.show');
bakerkretzmar commented 2 years ago

Ziggy's route() helper behaves just like Laravel's—it takes a route name and parameters and returns a URL string, it doesn't handle navigation. It looks like you probably want something like this:

<a :href="route('forms.show', form.id)"></a>