• Skip to primary navigation
  • Skip to main content
  • Skip to footer

JH Tech Services

A knowledgebase

  • Portfolio
  • Knowledgebase
  • About

Take over the ‘submit’ event in the Elementor Search form

December 12, 2021 by jer0dh

I could not get my javascript code to submit an get request using ajax in Elementor. I figured out that my search form was in a popup and not in the DOM until the popup was active. So when trying to attach and add the submit event, it never worked.

I’m sure there is another way but the quickest solutions I found was to use the jQuery ‘on’ function with delegation. So instead of attaching to the submit event directly like this:

$('form.elementor-search-form').on('submit', function {
   //do my stuff here
 });

I did the following:

$('body').on('submit', 'form.elementor-search-form', function(e) {
     //do my stuff here
  });
  • Knowledgebase

Footer

  • Portfolio
  • Knowledgebase
  • About

© 2023