0
これは私のサイドバーには表示されないようです。私はそれがページをリロードすると動作すると思われるので、レール4のTurbolinksと関係があると思う。どのようにこれを動作させるためにこれを変更する上で任意のアイデア?Rails 4ターボリンクコーヒースクリプトがロードされない
jQuery ->
category = $('#subject_category').html()
$('#subject_product').change ->
product = $('#subject_product :selected').text()
escaped_product = product.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
options = $(category).filter("optgroup[label='#{escaped_product}']").html()
if options
$('#subject_category').html(options)
$('#subject_category').parent().show()
else
$('#subject_category').empty()
$('#subject_category').parent().hide()
$ ->
category = $('#sidebar .category_select').html()
options = $(category).filter("optgroup[label='Car']").html()
if options
$('#sidebar .category_select').html(options)
$('#sidebar .category_select').parent().show()
else
$('#sidebar .category_select').empty()
$('#sidebar .category_select').parent().hide()
私の問題は、コーヒースクリプトの構文ですが、他の投稿が私の要求に対処しているかどうかはわかりません。これらはonloadイベントではありませんので、 – user2012677
'$ - >'は 'jQuery - >'の短縮形です。これは 'document ready'のショートカットです。この記事では、 'document ready'とturbolinksで何が違うのかを説明しています。私はそれがあなたの問題だと確信しています。 – slowjack2k
だから、 '$ - >'を '$(document).on" turbolinks:load "、 - >'に置き換えるべきですか? 'jQuery - >'のショートカットは何ですか? 'jQuery - >'を '$(document).on" turbolinks:load "、 - >'に置き換えるべきですか? – user2012677