mardi 25 avril 2017

Javascript in Ruby on Rails

I have a small doubt. Can anyone explain me how to include javascript in rails app and my code is a sidebar toggler in my website.

Mycode:

 $("#menu-toggle").click( function (e){
     e.preventDefault();
       $("#wrapper").toggleClass("menuDisplayed"); 
   });

Description: menu toggle is my icon, which gives a menu with items in it , when I click on it and wrapper is the place where my menu resides. I want this code to work in Rails app.

1) can anyone tell me how to change this code in rails appa and how to work it in it.

2) If there is a better code than this for javascript toggler button function, can you tell me the code in javascript and even in rails app.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire