Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,


I'm working on a ruby on rails project. In a particular view page, I have used jQuery. This page has a table with (say ) 10 columns. Initially only 5 columns is show and rest are hidden. For hiding columns I have used jQuery. I have included jquery-rails gem jquery-ui gem and all necessary changes to be done in application.js is done. But if I do not add
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

hiding is not working. I have added code snippet below.
PS added javascript inside head element; using turbolinks
If I remove jquery link ; hiding is not working.

Can anyone solve the below issue ? Thanks

What I have tried:

JavaScript
<html>
<head>

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
     
      <script type="text/javascript">
         $(document).ready(function(){

                 // to hide the week cols initially


                  <%  @colwno.each do |s|%> 
                        $('td:nth-child(<%=s%>)').hide();
                        $('#try1 th:nth-child(<%=s%>)').hide();
                       
                   <% end %>

      </script> 
Posted
Updated 28-Apr-16 19:02pm
v2
Comments
Karthik_Mahalingam 28-Apr-16 9:58am    
are you referring jquery file in application.js also ?
Supraja05 28-Apr-16 10:00am    
Hi, my application.js looks something like this:
//= require jquery
//= require jquery.purr
//= require jquery_ujs
//= require best_in_place
//= require jquery-ui
//= require best_in_place.jquery-ui
//= require best_in_place.purr
//= require turbolinks
..
//= require moment
//= require_tree .
Supraja05 28-Apr-16 10:02am    
Is the problem because ruby code is used inside javascript ?
Karthik_Mahalingam 29-Apr-16 1:01am    
Please use Reply button

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900