• Resolved dani1434

    (@dani1434)


    Hey there,

    I have two search forms on my website; one is the main search and the other is a search for a specific category. The ajax live search is working great on the main search, however I keep getting this error on the second search despite having the same header, footer, scripts etc on the page – am I missing something?

    Searchform 1:

    <form id="search" class="search-bar" role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>">
    <div class="wrap bar">
    <input id="s" name="s" placeholder="Search research reports and papers..." class="searchtext required" type="search" value="" />
    <input id="searchBtn" type="submit" value="Search" />
    </div>
    </form>

    Searchform 2:

    <form id="search" class="search-bar" role="search" method="get" action="<?php echo esc_url(home_url('/')); ?>">
    <div class="wrap bar">
    <input id="s" name="s" placeholder="Search research reports and papers..." class="searchtext required" type="search" value="" />
    <input type="hidden" value="251" name="cats" />
    <input type="hidden" value="evidencebank" name="refine">
    <input id="searchBtn" type="submit" value="Search" />
    </div>
    </form>


    Error message:
    Uncaught TypeError: Cannot read properties of undefined (reading 'replace')
    at s.position_results (script.min.js?ver=2.5:1:7193)
    at s.init (script.min.js?ver=2.5:1:1498)
    at new s (script.min.js?ver=2.5:1:427)
    at HTMLInputElement. (script.min.js?ver=2.5:1:9000)
    at Function.each (jquery.min.js:2:3129)
    at ce.fn.init.each (jquery.min.js:2:1594)
    at jQuery.fn. as relevanssi_live_search
    at HTMLDocument. (script.min.js?ver=2.5:1:9159)
    at e (jquery.min.js:2:27028)
    at t (jquery.min.js:2:27330)

    Thanks so much, you’ve built an amazing plugin.

    • This topic was modified 2 months, 1 week ago by dani1434.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Can I see the site? That would help figure out what’s wrong.

    Ensure both forms have search result div elements with different IDs. Duplicate IDs can trip things up. Relevanssi Live Ajax Search should fix this automatically, but depending on how your forms are built, this may be a problem.

    Thread Starter dani1434

    (@dani1434)

    Ah, that could be the case. Although, there is only one instance of the ID on a page.

    Search form 1 (working perfectly)
    https://lawfoundation.net.au/our-research-publications/

    Search form 2 (ajax not working)
    https://lawfoundation.net.au/evidence-bank-test/

    Thanks so much again.

    Plugin Author Mikko Saari

    (@msaari)

    The search form on the second page doesn’t have Relevanssi Live Ajax Search installed. The working form looks like this:

    <input id="s" name="s" data-rlvlive="true" data-rlvparentel="#rlvlive_2" data-rlvconfig="default" placeholder="Search research reports and papers..." class="searchtext required" type="search" value="" autocomplete="off" aria-owns="relevanssi_live_search_results_66e96539b48e8" aria-autocomplete="both">

    The second form doesn’t have the Relevanssi parameters:

    <input name="s" placeholder="Search research reports and papers..." class="searchtext required" type="search" value="">

    Is there a difference in how these pages are built?

    Thread Starter dani1434

    (@dani1434)

    No, they’re duplicates however the second one has two extra hidden fields!

    I installed the relevanssi ajax plugin and the main form added the relevanssi parameters automatically where as the second one doesn’t seem to populate the parameters. I did try putting in this

          data-rlvlive="true" data-rlvparentel="#rlvlive" data-rlvconfig="default"

    into the search input but it still returned with the same error, so i’m a bit at a loss!

    Thank you Mikko

    Plugin Author Mikko Saari

    (@msaari)

    In addition to that, you also need to add the <div id="rlvlive"></div> element to where you want the results to appear. That should fix this problem. I don’t know why one form gets the codes automatically and other doesn’t. The plugin uses get_search_form hook to inject itself to the form, so if one form triggers that and the other doesn’t, that would explain it.

    Thread Starter dani1434

    (@dani1434)

    That was it! I knew I was missing something. Thanks so much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.