Browse Source

Don't turbo cache page to make js function act each time

pull/182/head
baarkerlounger 4 years ago
parent
commit
78eb25a789
  1. 4
      app/views/form/page.html.erb
  2. 4
      app/views/layouts/application.html.erb
  3. 12
      app/webpacker/controllers/accessible_autocomplete_controller.js

4
app/views/form/page.html.erb

@ -1,3 +1,7 @@
<% content_for :head do %>
<meta name="turbo-cache-control" content="no-cache">
<% end %>
<% content_for :title, @page.header.present? ? @page.header : @page.questions.first().header.html_safe %>
<% content_for :before_content do %>

4
app/views/layouts/application.html.erb

@ -15,6 +15,10 @@
<%= favicon_link_tag asset_pack_path('media/images/govuk-apple-touch-icon-180x180.png'), rel: 'apple-touch-icon', type: 'image/png', size: '180x180' %>
<%= stylesheet_pack_tag 'application', media: 'all' %>
<%= javascript_pack_tag 'application', defer: true %>
<% if content_for?(:head) %>
<%= yield(:head) %>
<% end %>
<%= capybara_lockstep if defined?(Capybara::Lockstep) %>
<% if Rails.env.development? %>

12
app/webpacker/controllers/accessible_autocomplete_controller.js

@ -3,15 +3,11 @@ import accessibleAutocomplete from "accessible-autocomplete"
import 'accessible-autocomplete/dist/accessible-autocomplete.min.css'
export default class extends Controller {
static values = { enhanced: Boolean, default: false }
connect() {
if(!this.enhancedValue){
accessibleAutocomplete.enhanceSelectElement({
defaultValue: '',
selectElement: this.element
})
this.enhancedValue = true
}
accessibleAutocomplete.enhanceSelectElement({
defaultValue: '',
selectElement: this.element
})
}
}

Loading…
Cancel
Save