jquery - The right way to include page specific Javascript in Rails -
I want to include it, for example:
  jQuery. Ready (function ($) {$ ('# my-modal'). Modal (option)});   In my case in a specific place in a Rail App file / model / mymodal.html. Called ARB. There and only there.
I do not understand that if I put it in the property then why not do it with all the pages, thanks so much!
These are some useful moves
# 1 file js >
 // require_tree.  application.js  at  your.js  for code-per compound add code  on Config / application.rb  >:  config.assets.precompile + =% w (your.js)  # 2 inserted non-layout in specific file (not recommended)
  mymodal.html. ARB  
Put your JS script with javascript tag on # 3 .. this ..
 Change your code to  layout / yourlayout.html. Enter in ARB  and use  if ..and ..  argument 
example:
& if; Current_page? (Yourspecific_path)%> & Lt; Script language = "text / javascript" & gt; Your javascript is here .. & lt; / Script & gt; & Lt;% end% & gt; Read more about
  current_page  
 or   Example:       if you want # 1 and # 3 too The file can be added to   Cheers  request.fullpath  Use path   
  
  & lt;% if request.fullpath == youpecific_path% & gt; & Lt; Script language = "text / javascript" & gt; Your javascript is here .. & lt; / Script & gt; & Lt;% end% & gt; Read more about   request.fullpath   .js   
Comments
Post a Comment