Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    184
    Thanks
    140
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    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>
    Last edited by DanInMa; 08-27-2012 at 10:55 PM.

  • Users who have thanked DanInMa for this post:

    jason_kelly (08-29-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •