ruby on rails - Jquery/Datepicker works locally but not in production (heroku) -


the javascript error message keep seeing on browser inspector says

"referenceerror: can't find variable $" on application-ccd035fs...... .js:1" 

it works fine locally though. based on error i'm imagining isn't recognizing jquery syntax. not sure how fix it. appreciated!

my application.js follows:

//= require jquery //= require jquery-ui //= require jquery_ujs //= require_tree .  $(document).ready(function(){     $('#showdate').datepicker({date_format: "dd/mm/yyyy", altfield: '#mile_date', altformat: 'yy-mm-dd'});  }); 

my gem file has gem:

'jquery-rails', '~> 2.3.0' 

my layout has following in head:

<%= javascript_include_tag "application" %> 

the relevant form code follows:

<div class="field">     <%= f.label :date, "date:" %><br />     <%= f.text_field :date, :id => "showdate" %>  </div>     <%= f.hidden_field :date, :id => "mile_date" %> 

probably not best put code application.js indicated line in file itself.

// it's not advisable add code directly here, if do, it'll appear @ bottom of // compiled file. 

try in view

<div class="field">     <%= f.label :date, "date:" %><br />     <%= f.text_field :date, :class => "datepicker" %>     <%= f.hidden_field :date %> </div> 

then call coffescript in file (this allow build many datepickers want adding class datepicker input element anywhere in application)

$ ->   $("input.datepicker").each (i) ->     $(this).datepicker     altformat: "yy-mm-dd"     dateformat: "dd/mm/yy"     altfield: $(this).next() 

also did not mention if have jquery-ui-rails in gemfile if don't may part of issue.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -