Hi, I am using Inertia JS with react, i just want to know how can it force and prevent the Router functions like visit or post not to change the url?
For example in react part: (router.visit or router.post)
const sendToEncodeHtml = () => {
router.visit("/admin/dashboard/builder/encode-html", {
method: "post",
data: {
html: htmlContent,
metadata: { count, timestamp: Date.now() },
},
preserveState: true,
preserveScroll: true,
replace: true,
onSuccess: (page) => {
console.log("Successfully sent to encode_html");
console.log("Response props:", page.props);
},
});
};
And Phoenix controller:
def encode_html(conn, %{"html" => html_content, "metadata" => metadata} = _params) do
IO.inspect(html_content, label: "Received HTML")
IO.inspect(metadata, label: "Received Metadata")
conn
|> assign_prop(:encode_response, %{
success: true,
timestamp: metadata["timestamp"],
received_html: html_content
})
|> render_inertia("PageBuilder")
end
As i try this; it changes the admin/dashboard/builder to admin/dashboard/builder/encode-html
Thank you in advance






















