CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Jquery UI Datepicker doesn't show again when link is clicked (http://www.codingforums.com/showthread.php?t=271559)

jason_kelly 08-27-2012 07:22 PM

Jquery UI Datepicker doesn't show again when link is clicked
 
Hello,

I need your help.

I seem to have this working except for the fact that once the link is clicked, the datepicker opens, then I select a date and all is good and well, then once I try to click the link again, the date picker does not open again.

What am I doing wrong?

Code:

<html>

<head>

<!-- LOAD JQUERY LIBRARY: --> 
        <link        href="jq/jquery-ui.css"                        type="text/css"        rel="stylesheet" />
        <script src="jq/jquery.min.js"                        type="text/javascript"> </script>
    <script src="jq/jquery-ui.min.js"                type="text/javascript"> </script>

<script type="text/javascript">

function test() {
 
var datePickerValue = null;
 
$("#d1").datepicker().datepicker("show").change(function ()
{
        $('#d1').datepicker({onSelect:  datePickerValue = $(this).val() }).hide();

  alert("You picked: " + datePickerValue);
});
 
 
 
}


</script>



</head>

<body>

<div id="d1"></div>
<a href="javascript:test()">test</a>

</body>

</html>

Thanks for all your help in advance,

Cheers,

Jay

DanInMa 08-27-2012 10:43 PM

I'm sorry but I'm not sure you're going about this the right way.

1. you are trying to use the datepicker in a non-standard way, which I suppose is possible, but thats not the way it's meant to be used. - It's generally attached directly to a form input field of some kind.

2. - why datepicker().datepicker("show") ?


3. .change() is only for inputs, textareas and selects.

perhaps state what you are trying to accomplish and I can give you a basic example?


Ill give you a basic example.




Code:


<html>
<head>
<link        href="jq/jquery-ui.css"        type="text/css"        rel="stylesheet" />
<script src="jq/jquery.min.js"        type="text/javascript"> </script>
<script src="jq/jquery-ui.min.js" type="text/javascript"> </script>
<script type="text/javascript">
$(document).ready(function(){

$('#d1').datepicker({
onSelect:function(){
alert($(this).val())
}

});

</script>
</head>

<body>

<form action="/">
 Choose Date: <input type="text" id="d1">
</form>
</body>
</html>



All times are GMT +1. The time now is 10:54 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.