Date with bootstrap does not run in my project

Asked

Viewed 135 times

2

I need to place a component to select dates in a filter in my project. As I use bootstrap, I need to place dates with this component. It turns out the examples I picked up on the internet, I couldn’t make it work, one of them here

Any help, thank you.

I put this guy in my . js

$('.datepicker').datepicker()

And this in my view without value, no default date.

<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
  <input class="span2" size="16" type="text" value="12-02-2012">
  <span class="add-on"><i class="icon-th"></i></span>
</div>
  • then put the tests you have done as per the rules of the community. so the staff will help you

  • This line of the script runs before or after input has been added to the DOM?

  • Did you do datepicker’s css includes and js? It seems to work normally, see http://jsfiddle.net/uya9b4d8/

  • It didn’t have the includes. Then include the datepicker . js and the css and even then, it doesn’t work and the fiddle without problems. There were some errors (404 and 500) and before there were, just that I didn’t recognize the function, but after include the error disappeared and this appeared. One of them I solve here, I think solving one, solve the other. Then put, after removing the error to see if it worked or not.

1 answer

1


At your command:

$('.datepicker').datepicker()

If it’s exactly as you said, you need to add to css class datepicker in his input.

<input class="span2 datepicker" size="16" type="text" value="12-02-2012">

Otherwise the jQuery does not find the element to then apply the plugin.

  • 1

    That’s right, James. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.