Hi community,
I cannot figure out how to prevent default enter key behaviour and simulate button click? I’m trying to mix wappler native functions + custom javascript as I don’t know how to achieve it but still no luck, the issue probably is that it’s a datastore update involved in this. I’m trying to use this with no luck
dmx-on:keydown.enter="run(\[{runJS:{outputType:'text',function:\`$event.preventDefault()\`}},{wait:{delay:200}},{run:{outputType:'text',action:\`serverconnectform1.submit()\`}}\])">
<script>
document.addEventListener('keydown', function (e) {
if (e.key === 'Enter' && e.target.id === 'text_social_media_link') {
setTimeout(() => e.target.blur(), 200); // flush last keystroke before submit
}
});
</script>
a working button code that I’m trying to simulate is this simple:
<input type="hidden" name="social_media_id" dmx-bind:value="social_media_id">
<input type="hidden" name="link" dmx-bind:value="link">
<!-- Save button (right) -->
<button form="serverconnectform1" class="btn rounded-pill d-flex align-items-center gap-1 btn-sm btn-primary" dmx-on:click="run(\[{wait:{delay:200}},{run:{outputType:'text',action:\`serverconnectform1.submit()\`}}\])" id="btn_save_social_media">
<i class="fas fa-check"></i>
Išsaugoti
</button>
any available methods to simulate a button click ?