I have a date text box to which I sometimes want to add a DatePicker, because I have some of my own text processing scripts that process partial date strings. However, calling .remove or .destroy leaves the text formatting behavior in the input field, which converts my string "8" to "8/18/2010". Even worse, if I start deleting, he confidently assumes that, having reached "8/18/20", I really wanted to "8/18/2020".
What would be the best way to completely, completely, make-it-like-it-never-was remove datepicker from my page? I can also use it if it just ignores the text that I enter completely, but in this case I would prefer it to be displayed twice with a click / image as a button, not always.
edit:
this is all in jqGrid, where "selector" is the text field in the date column:
function showPicker(selector) { $(selector).datepicker({ onClose: function() { $(selector).datepicker('remove'); // or 'destroy' or $('.datepicker').remove(); or $(this).datepick('remove'); } }); }
This prevents me from returning, but not manipulating my text box. No other code (which I know) manipulates this field content, just jqGrid watches the enter key to send data. Looking at the code of the generated page, the datepicker div is still at the bottom.
edit2: I get the same behavior if I do this:
<html> <body> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(document).ready( function(){ $("#pickle").datepicker({ onClose: function(){ $(this).datepicker('remove'); } }); }); </script> <input type="text" id="pickle" /> </body> </html>
This causes the same behavior as me, but I change it to "destroy", but not on my page. Odd
jquery-ui datepicker
Groxx Aug 18 '10 at 21:47 2010-08-18 21:47
source share