Skip to content

Instantly share code, notes, and snippets.

@salami-art
Created March 5, 2018 11:34
Show Gist options
  • Save salami-art/7ce6685159f06f0bc55168df6dc66e1d to your computer and use it in GitHub Desktop.
Save salami-art/7ce6685159f06f0bc55168df6dc66e1d to your computer and use it in GitHub Desktop.
<% content_for :footer_scripts do %>
<script type="text/javascript">
<% if @current_province.present? %>
$('#provinces').val('<%= @current_province.name.titleize %>');
<% end %>
<% if @current_speciality.present? %>
$('#specialities').val('<%= @current_speciality.profession.capitalize %>');
<% end %>
</script>
<% cache 'docdropdown_data' do %>
<script type="text/javascript">
application.setData('suggestions_for', {
'provinces' : <%= @most_clicked_cities.to_json.html_safe %>,
'specialities' : <%= @most_clicked_specialities.to_json.html_safe %>
});
application.setData('options_for', {
'provinces' : {<%= @other_provinces.collect { |province| "\"#{province.name}\" : { id : \"#{province.region.slug}/#{province.name.downcase}\"}" }.join(", ").html_safe %>},
'specialities' : {<%= @specialities.collect { |speciality| "\"#{speciality.profession.capitalize}\" : { id : \"#{speciality.slug}\"}" }.join(", ").html_safe %>}
});
</script>
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment