Trigger SearchWidget search from another set of controls

Posted by Community Admin on 04-Aug-2018 23:48

Trigger SearchWidget search from another set of controls

All Replies

Posted by Community Admin on 11-Jun-2014 00:00

I'm trying to trigger the Search Widget from another set of controls I'm using for the mobile version of my Sitefinity site. I've been able to use jQuery to copy the value from the mobile textbox to the Search Widget's text box. But I'm having trouble triggering the submit button in the Search Widget.

This is what the search widget looks like

div id="m_nav_primary_ctl00">
    <fieldset id="m_nav_primary_ctl00_ctl00_ctl00_main" class="sfsearchBox">
    <input name="ctl00$m_nav_primary$ctl00$ctl00$ctl00$searchTextBox" type="text" id="m_nav_primary_ctl00_ctl00_ctl00_searchTextBox" class="sfsearchTxt">
    <input type="submit" name="ctl00$m_nav_primary$ctl00$ctl00$ctl00$searchButton" value="Search" onclick="return false;" id="m_nav_primary_ctl00_ctl00_ctl00_searchButton" class="sfsearchSubmit">
</fieldset>
</div> 

This is what the mobile controls look like<div class="base"> 

<div class="sfContentBlock"><
input type="text" id="searchbox" name="search" size="40">
</div>
</div>
<div class="base">
<div class="sfContentBlock">
<a href="#" id="search_btn">
<img style="border-width: 0px; border-style: solid;" id="btn_search" src="/image/button_search.jpg" alt="Search">
</a>
</div>
</div>  

This is what my javascript looks like

jQuery(function ()

    jQuery('#search_btn').click(function ()
   
        jQuery('#m_nav_primary_ctl00_ctl00_ctl00_searchTextBox').val($('#searchbox').val());
        jQuery("#m_nav_primary_ctl01_ctl00_ctl00_searchButton").click();
    );
);

Posted by Community Admin on 16-Jun-2014 00:00

Hi Raymond,

Please check if the returned value of the search button is not an array. If so you could try to click() the button by:

jQuery("#m_nav_primary_ctl01_ctl00_ctl00_searchButton")[0].click();


Regards,
Svetoslav Manchev
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed