Reply To: Behaviour not to be redirected when searching

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Behaviour not to be redirected when searching Reply To: Behaviour not to be redirected when searching

#3433

Ernest Marcinko
Keymaster

Hi!

I'm suspecting a 3rd party javascript (probably from another plugin or theme) which automatically submits the form when pressing the enter key. The search tries to automatically prevent this behaviour, but depending on the method it might fail.

The best you can try is the following javascript code:

jQuery(document).ready(function($){
  var scope = $;    
  if (typeof aspjQuery != "undefined")
      scope = aspjQuery;     
  scope(".proinput input.orig").keydown( function(e) {
    if (e.which === 13) {
      e.preventDefault();
      e.stopPropagation();
      if (typeof(e.stopImmediatePropagation) != "undefined")
        e.stopImmediatePropagation();
    }
  });
  scope("input.orig").parent().submit( function(e) {
    if (e.which === 13) {
      e.preventDefault();
      e.stopPropagation();
      if (typeof(e.stopImmediatePropagation) != "undefined")
        e.stopImmediatePropagation();
    }
  });
});

Try to add it to the page footer or header. It might work, but if another javascript file is interfeering with the event listeners this might not work.

Also, try to clear your page as well. If you are using any kind of CDN, then their cache as well. The cache can prevent such settings from application.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)