tighten / ziggy

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

Set the defaults object in client #620

Closed sbc640964 closed 1 year ago

sbc640964 commented 1 year ago

Description

Add an option to update the selector object from the client.

Suggestion

Add an option to update the selector object from the client.

The defaults object is currently updated on the server side, working with inertiajs for example will not take into account that the object is initialized only for the first time.

I have an application that when I'm inside one of its resources I want the parameter to be default, because it forces me to use it in a lot of places.

If I browse directly to the item resourse page, the default is indeed set, but if I browsed to the index of the resource, the resource I enter will not be the default, since it has already been initialized upon entering the index (as null).

I would appreciate a solution.

Alternatives

I don't know if this is correct, but I ended up doing it like this:

Ziggy.defaults = {...Ziggy.defaults, [key]: value}