4 rails, 3 turboprop, partial replacement does not work
I am trying to use rails / turbolinks 3 and want to do a partial replacement, but no luck with that. Here is the code:
Gemfile
gem 'turbolinks', github: 'rails/turbolinks'
(shows using 3.0.0, so the problem is not that turbolinks are included in app..n.js).
router:
root 'home#index'
get '/partial1' => 'home#partial1', as: 'partial1'
get '/partial2' => 'home#partial2', as: 'partial2'
controller
class HomeController < ApplicationController
def index
end
def partial1
render change: 'partial1'
end
def partial2
render change: 'partial2'
end
end
Layouts / application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Turbo</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<div>
this is home
<%= link_to("partial asd1", partial1_path) %>
<%= link_to "partial 2", partial2_path%>
</div>
<div id="partial1" data-turbolinks-temporary>
<p>her</p>
</div>
<div id="partial2">
<p>here is partial</p>
</div>
<%= yield %>
</body>
</html>
But it does not replace these partial ones, it works just as regularly. I also tried to install turbolinks: true
and it displays Turbolinks.replace('some html', {change: ['partial1']})
but also nothing happens. I also tried e.preventDefault and Turbolinks.visit('/partial1', {change: 'partial1'})
as well did not work and also called Turbolinks.replace('some html', {change: 'partial1'})
. Turbolinks js is loaded in the browser. And in dev it shows the challenge Turbolinks.visit
. Tried it on different machines.
If anyone has done this, please tell me how you did it.
source to share
No one has answered this question yet
Check out similar questions: