gavin
gavin

Reputation: 1

using multiple instances of datepicker on the same page

I apologize for the duplicate issue, but the issue was "closed" and I have new information.

The issue is that I have two date pickers and when you click one the calendar works fine, but then you click the other and it doesn't come up unless you click elsewhere on the page and then back.

This was tested on jsfiddle.net and the bug was not replicated, but I replicated the bug with nothing but the following code:

<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript" src="jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery.ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#frompicker").datepicker();
    $("#topicker").datepicker();
});
</script>
</head>
<body>
<input id="frompicker" class="dp" type="text">
<input id="topicker" class="dp" type="text">
</body>

Upvotes: 0

Views: 4666

Answers (2)

KarateKid22
KarateKid22

Reputation: 31

I found that this worked pretty well:

$(document).ready(function(){
   $(".dp").datepicker();
});

<input id="frompicker" class="dp" type="text">
<input id="topicker" class="dp" type="text">

use the class to call the function. just remember to give them different names to get the value

Upvotes: 2

Anthony Hatzopoulos
Anthony Hatzopoulos

Reputation: 10537

Works perfectly, http://jsbin.com/ajapih/1/edit#html,live

Make sure your <script ... src="jquery-whatever-files.js" are in the right place. The way you have it they should be in the same folder as your html file. Also open your firebug console and check for javascript errors.

Upvotes: 0

Related Questions