Hotwire: building responsive Rails apps
09-Aug-2022 830
On June 25, 2013, Rails 4 was released introducing Turbolinks. What Turbolinks are doing for "responsiveness" of Rails? Turbolinks intercept all link clicks and instead of sending regular GET request it sends asynchronous Javascript request (AJAX) to fetch HTML. It then merges the head tag of the fetched page and replaces the whole body tag of the page, so there is no full page reload. No stylesheets or scripts reloading, which meana a faster page navigation. But it still is replacing the whole body, not only changed parts of the page.But what if you want to reload only parts that changed? Well, you could use Rails AJAX helpers, when you mark some elements as data-remote='true', which makes those element sending AJAX GET/POST requests instead of regular GET/POST requests. And Rails responds with generated JS code, which then is executed by the browser to dynamically update those parts of the page.
Hotwire: building responsive Rails apps #ruby #rubydeveloper #rubyonrails #Hotwire: #building #responsive #Rails #hotwire: https://rubyonrails.ba/link/hotwire-building-responsive-rails-apps