jquery - Rails 3.2.13 Javascript Asset Pipeline -


i working on rails 3.2.13 app, , encountering following problem:

the javascript files wrote in app/assets/javascripts/ directory don't seem run.

i have js code in file called menu_list.js in app/assets/javascripts/ directory, not anything. whereas when put same code on view page in tag, works.

<script>$("#sortable").sortable();</script> 

here's application.js file:

//= require jquery //= require jquery_ujs //= require jquery.purr //= require jquery-ui //= require best_in_place //= require bootstrap //= require bootstrap-switch //= require_tree . 

my menu_list.js file:

$(function() {   $("#sortable").sortable(); }); 

it not make sense me, thought //= require_tree . include javascript files in directory. tried other javascript files too, don't seem have effects.

$("#sortable").sortable(); 

if have in app/assets/javascripts/menu_list.js run script loaded, not want. want run above code @ least after dom has loaded page , not before.

$(function() {   $("#sortable").sortable(); }); 

if environment you're running in :development, , have following in layout

<%= javascript_include_tag "application" %> 

you see separate <script> tag every javascript file sprockets loading. //= require_tree . will pick app/assets/javascripts/menu_list.js file.

i suggest making sure don't have precompiled version of assets in place running following in shell

rake assets:clean 

you can force debug mode (individual <script> tags each file) adding :debug option above include tag

<%= javascript_include_tag "application", debug: true %> 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -