Modify text area content with Alpine
I'd like my text area to automatically add this line in the content:
[Edited on 11-6-2023]
on blur.
(Except when the last line is exactly that already.)
I already have some autosave magic going on in afterStateUpdated
, so I'd like to have this functionality client side with Alpine.
Do I need a custom field? Or can I add Alpine to a standard Textarea component?
I see ->extraAlpineAttributes()
but I can't find that in the docs.
I tried playing around with a custom field, but I have no idea how to change the value while playing nice with Alpine/Filamen state.1 Reply
I've looked at a plugin and came up with the following. Custom component based on Textarea, with some stuff added in the blade:
I'm still confused about why I need both
state: $wire ...
and manually getting and setting the x-ref.
But... the important part is that it works! Just leaving this code here for others.
Please let me know if I got stuff wrong or could have done easier/better.