В основном у меня есть страница-страница для b_page, и я отобразил новую часть внутри (для page_posts), и кнопка отправки для нее работает только в том случае, если она обновлена или если ссылка открыта непосредственно из браузера. Я проверил и нет отсутствующих divs или нераспечатанных тегов и т.д., Поэтому это не проблема HTML.
Возможно, это проблема Turbolinks, потому что это происходит практически во всем приложении, и если это так, то мое application.js.erb
:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It not advisable to add code directly here but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery.ui.all
//= require jquery.turbolinks
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-tagsinput
//= require sync
//= require masonry/jquery.masonry
//= require jscolor
//= require_tree .
//= require owl.carousel
//= require turbolinks
Как я могу это исправить? Здесь ссылка на show.html.erb
.
Вы должны использовать $(document).on('ready', function(){})
Измените его на $(document).on('turbolinks:load', function(){})
, это заставляет JavaScript загружать на просмотре временной страницы.