Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created February 16, 2011 19:55
Show Gist options
  • Save brandon-beacher/830048 to your computer and use it in GitHub Desktop.
Save brandon-beacher/830048 to your computer and use it in GitHub Desktop.
- content_for(:end) do
:javascript
var subdivisions_by_district = {};
subdivisions_by_district['all'] = #{MlsListing.on_market.distinct_subdivisions.collect { |s| s.subdivision }.to_json };
- District.all.each do |district|
:javascript
subdivisions_by_district['#{district.id}'] = #{MlsListing.on_market.district_id(district.id).distinct_subdivisions.collect { |s| s.subdivision }.to_json };
:javascript
$('#search_subdivision').autocomplete({
source: subdivisions_by_district['all']
});
$('#search_district_id').change(function () {
var district_id = $("#search_district_id").val();
if (!district_id) { district_id = 'all' };
$('#search_subdivision').autocomplete('option', { source: subdivisions_by_district[district_id] });
} );
$("input#search_query").placeholder({message: "Enter a single MLS#"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment