Trigger SearchWidget search from another set of controls
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();
);
);
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();