-4

I download the bootstrap-datepicker.js and include it in my application .js file. It is not working in view

 <div class="well">
<div id="dp5" class="input-append date" data-date-format="dd-mm-yyyy" data-date="12-02-2012">
<input class="span2" type="dp5" readonly="" value="12-02-2012" size="16">
<span class="add-on">
<i class="icon-th"></i>
</span>
</div>

It is not displaying the calender for date. where m i wrong?

my application.js file is

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-datepicker

//= require picker
//= require_tree .

$('#dp5').datepicker()
Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
regmiprem
  • 735
  • 2
  • 14
  • 41

1 Answers1

4

Add //= require_self to application.js

this includes its own file contents too. This has to be done explicitly.

also keep the application.js formatted

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-datepicker
//= require picker
//= require_tree .
//= require_self

$(function() {
   $('#dp5').datepicker()
 });

// Do not keep bank spaces between included files.

I would suggest to create a new js file and add contents in it and then include it in application.js

keep application.js as a index file

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
  • its my own js just m namin it picker it is for select all check box js. n working fine in my app – regmiprem Aug 23 '12 at 06:51
  • aaahhh I got it, check updated answer, apply the datapicker when dom loads – Pritesh Jain Aug 23 '12 at 06:51
  • my form has the format like <%= f.radio_button :status, 2 %>Trash How can i bring date picker in this formate in my form? <%= f. %> ? – regmiprem Aug 23 '12 at 07:12
  • Now the datepicker works successfully. Now i want to use it in my form in rails . which have formate like
    <%= f.input :Projects %> <%= f.date (datepicker)%>
    How can i do that such that value of date come in date?
    – regmiprem Aug 23 '12 at 07:50
  • @regmiprem, I would ask you to open a new question to this, too much things in one question may confuse another users. – Pritesh Jain Aug 23 '12 at 08:42
  • ok. I already opened http://stackoverflow.com/questions/12087794/how-can-i-put-the-bootstrap-datepicker-in-my-form-and-have-the-value-in-date-par – regmiprem Aug 23 '12 at 08:43