0

I know that we can use element.dispatchEvent(custom_event) to dispatch a custom event that we defined. My question is how to dispatch built-in events, such as submit, click, change, ...

I write form.on('submit', function(){}) to hanlde form submitting event. Then, I want to dispatch submit form by clicking on an X element.

X.on('click', function(){
    // dispatch form submit here
});

P/s: I'm using PrototyeJS

5
  • Have you tried dispatchEvent with the name of a built-in event type? Commented Oct 2, 2014 at 15:21
  • @Bergi dispatchEvent doesn't accept string as parammeter's value Commented Oct 2, 2014 at 15:24
  • Then what is the element.dispatchEvent('custom-event') that you used? Commented Oct 2, 2014 at 15:25
  • @Bergi sorry, I just edited my question, it should be element.dispatchEvent(custom_event) Commented Oct 2, 2014 at 15:28
  • @Bergi the simulate works fine. Hope a built-in way came realy soon. Thank you. Commented Oct 2, 2014 at 15:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.