dimanche 22 mars 2015

How to solve error regarding jquery in Rails-3

I am getting one issue while some jquery script links are executing in Rails application.html.erb file.Actually i am trying to open calender while user will click on text field using one third party jquery library. After the page loading it is not happening like that and no rails error but in console option i am getting the following error.



Uncaught TypeError: Cannot read property 'createPlugin' of undefined


I think the above error due to page is not finding the appropriate script files given via links in application.html.erb but by using simple HTML and JS it is working properly.


Some of my codes are given below.


application.html.erb



<!DOCTYPE html>
<html>
<head>
<title>MakeCalender</title>
<link href="/assets/jquery.datepick.css" rel="stylesheet">
<script src="/assets/jquery.plugin.js"></script>
<script src="http://ift.tt/1h847p1"></script>
<script src="/assets/jquery.datepick.js"></script>
<script src="/assets/common.js"></script>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<% if flash[:color]=="valid" %>
<div class="flash-message">
<div class="container container_12 clearfix">
<div class="grid_12">
<p><%=flash[:notice]%></p>
</div>
</div>
</div>
<% elsif flash[:color]== "invalid"%>
<div class="flash-message">
<div class="container container_12 clearfix">
<div class="grid_12">
<p><%=flash[:alert]%></p>
</div>
</div>
</div>
<% else %>
<div class="flash-message">
<div class="container container_12 clearfix">
<div class="grid_12">
<p><%=flash[:notice]%></p>
</div>
</div>
</div>
<% end %>
<%= yield %>

</body>
</html>


views/calenders/index.html.erb



<%= form_for :calenders,:url => {:action => 'create'} do |f| %>
Enter Your Date :<%= f.text_field :date_today,placeholder:"Please enter your date",:id => "popupDatepicker" %>
<%= f.submit "Submit" %>
<% end %>


javascript/common.js



$(function() {
console.log('datepick');
$('#popupDatepicker').datepick();
});


Please help me to resolve this issue after checking the code.


Aucun commentaire:

Enregistrer un commentaire