Assign an Action to an HTML Element

itsjakefromstatefarm:
Is there a way to assign an action (not a named action) to an HTML element within an HTML block? For example,

<button click="action('showModal', {'body': 'This is a modal.'})" class="rounded-lg p-2 px-3 bg-indigo-100 text-indigo-500 text-xl hover:bg-indigo-500 hover:text-white transition-all"><i class="fa-regular fa-list-check"></i><span class="ml-4 text-base font-semibold">Actions</span></button>

Hassan Mukhtar:
Yup you can do @click=namedAction(‘showModal’)


itsjakefromstatefarm:
What about unnamed actions?


Hassan Mukhtar:
O my bad I misread the question


itsjakefromstatefarm:
No problem at all


itsjakefromstatefarm:
@Hassan Mukhtar Any chance we can do that? Assign unnamed actions to HTML elements?


Hassan Mukhtar:
I’m not entirely sure, I think @Andrew Dam or @Christina Saran might have a better idea


Andrew Dam:
Any specific reason you can’t use a named action?


itsjakefromstatefarm:
No, I suppose I could. This specific use-case just didn’t seem like a “Global” action, more of a local action.


itsjakefromstatefarm:
Is there a way to pass HTML through to a named action that could then be shown on the modal?


Andrew Dam:
The @click accepts any JavaScript, but BF actions don’t have an associated JS function (aside from namedAction).


itsjakefromstatefarm:
I see


Andrew Dam:
You could escape the HTML and pass it as a string into the options of the named action.


Christina Saran:
namedActions also call the local page namedaction, as well as global namedactions


itsjakefromstatefarm:
Great point @Christina Saran, that’s how I’ll tackle this. Thanks!