Is there a way to select Partial Mode on button?
I researched and I do not think it is possible, but it would be nice to do something like:
2 Replies
Yes, you can specify the replacement mode for a
<Partial>
component in Fresh, which allows you to control how content is integrated into the active page when using partials. According to the documentation, there are three distinct merge modes you can use:
- replace
- Swap out the content of the existing partial (default)
- prepend
- Insert the new content before the existing content
- append
- Insert the new content after the existing content
Here's an example from the documentation on how to use the mode
prop with a <Partial>
component:
However, the f-mode
attribute you're referring to does not exist in the documentation. Instead, you should use the mode
prop directly on the <Partial>
component to specify how the content should be integrated.
For buttons, the documentation mentions that the f-partial
attribute is scoped to <a>
, <button>
, and <form>
elements. This means you can use f-partial
with a button, but you would still need to use the mode
prop on the <Partial>
component to specify the replacement mode.
Here's an example of how you might use f-partial
with a button, keeping in mind that you'll need to define the corresponding partial route and component:
And in your partial component, you would specify the mode
:
Remember to define the partial route and component according to your application's needs. 🦕Actually, the mode is indicated by <Partial that is coming, not current one.
So, I just added a param at my link and my component know how to handle with.