Created
October 19, 2010 21:16
-
-
Save jkeck/635142 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="searchbox"> | |
<h2 class="search"><%= label_tag(:q, "Search ") %></h2> | |
<% form_tag root_path, :method => :get do %> | |
<span id="search_box_and_link"> | |
<%= text_field_tag(:q, localized_params[:q], :class=>"search") %> | |
</span> | |
<noscript> | |
<%= label_tag(:search_field, " in ") %> | |
<%= select_tag(:search_field, options_for_select(search_fields, h(localized_params[:search_field])), :title => "Targeted search options") %> | |
</noscript> | |
<span id="split_button" style="display:none;"> | |
<div class="button_set"> | |
<button id="run">Search</button> | |
<button id="select">select</button> | |
</div> | |
</span> | |
<%= hidden_field_tag(:hidden_search_field, h(localized_params[:search_field])) %> | |
<noscript> | |
<%= submit_tag 'search', :class=>'submit' %> | |
</noscript> | |
<% end %> | |
</div> | |
<script type="text/javascript"> | |
// your jQueryUI button() and buttonset() functions | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// Display the split button | |
$("#split_button").toggle(); | |
// change the name of the hidden_search_field so the form sends the param along properly for JS enabled browsers, but defaults to the drop down for non-js browsers. | |
$("#hidden_search_field").attr("name","search_field"); | |
}); | |
// in the onclick event for the item in your drop down. You will need some way of determining what the value to pass for the search_field param is. I put the value that I want to pass as the search_field parameter as the class of the element that the user is clicking on. | |
$('#hidden_search_field').attr('value',$(this).attr("class")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment