0

How I could dispatch a custom event from '#input1' in this function?

What i tried:

export function captcha1_verified() {

        $w('#input1').show();
    
        const myEvent = new CustomEvent("myevent", {
            detail: {},
            bubbles: true,
            cancelable: true,
            composed: false,
        });
    
        $w('#input1').dispatchEvent(myEvent);
    }

Error: TypeError: $w(...).dispatchEvent is not a function

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
Cesar
  • 41
  • 2
  • 5
  • 16
  • Does this answer your question? [dispatchEvent() is not a function](https://stackoverflow.com/questions/70080625/dispatchevent-is-not-a-function) – Peterrabbit Jan 16 '23 at 19:18
  • @Peterrabbit you linked the same question twice, and it didn't answer the question, the problem is finding how to make dispatchEvent work with Wix syntax. – Cesar Jan 16 '23 at 19:28
  • Yes sorry I got tangled up, and I thought you were with jQuery. Anyway I found this that seems to be the same problem https://www.wix.com/velo/forum/coding-with-velo/custom-element-dispatch-event – Peterrabbit Jan 16 '23 at 20:06
  • You can't use dispatchEvent like that on a Wix Element. Maybe try explaining what you're trying to accomplish and we can help you figure out how to do that within Velo. – Sam Jan 18 '23 at 08:41

0 Answers0