Metro-UI-CSS icon indicating copy to clipboard operation
Metro-UI-CSS copied to clipboard

DatePicker on date-selected not working

Open EricBabin opened this issue 12 years ago • 6 comments

Hi

I'm trying to capture the event when the date gets changed and I'm not sure how to do it. With the old .95a version I could use the date-selected event but I can't seem to get it to work with version 2.0.27. Here is my html and script.

<div>
    <div id="dtpStartsOn" class="input-control text span3" data-role="datepicker" data-date="2014-01-01" data-effect="slide" data-format="yyyy-mm-dd" >
        <input id="txtDate" type="text"  />
        <button class="btn-date" type="button"></button>
    </div>
</div>

<script type="text/javascript">

    $(document).ready(function () {
        $('#dtpStartsOn').on('date-selected', function (el, dateString, dateMoment) {
            alert('date-selected');
        });
    });

</script>

EricBabin avatar Feb 02 '14 14:02 EricBabin

For the moment there is no date-selected trigger anymore

ghost avatar Feb 02 '14 15:02 ghost

is there any other possibility, to read this date ?

SiSoSnooP avatar Feb 03 '14 16:02 SiSoSnooP

Yes, I think so. Try it like that:

$("#datepicker").datepicker({selected: function(dateString, dateObject) {
 alert('date-selected');
}});

ghost avatar Feb 03 '14 16:02 ghost

yes it works.. but, we can change this date on lifetime ? e.g. $('#datepicker').setDate("2014-02-02" );

SiSoSnooP avatar Mar 07 '14 13:03 SiSoSnooP

Have you solved the problem?

Would you be able to change the date?

Thanks and regards

eddiedu avatar Jul 23 '14 03:07 eddiedu

i tried it like you said it but it didnt work. I am trying to do exactly as what is done in the event binding example of metro UI. But no matter what i try it doesn't work i have tried this:

<div class="input-control text" data-role="datepicker" data-on-select="alert(d +'\n'+ d0)">
                            <input type="text">
                            <button class="button"><span class="mif-calendar"></span></button>
                        </div>

it dint work and i have tried this too:

$("#datepicker").datepicker({selected: function(dateString, dateObject) {
 alert('date-selected');
}});

my code is:

$(function() {
	// Setzte aktuelles Datum
        $("#AktuellesStartDatum").datepicker({selected: function(dateString, dateObject) {
          console.log('AktuellesStartDatum  date-selected');
        }});
        
        $('#AktuellesStartDatum').on('date-selected', function (el, dateString, dateMoment) {
            alert('date-selected');
        });
        
	$("#AktuellesStartDatum").datepicker('destroy');
	$("#AktuellesStartDatum").datepicker({ date : new Date() });
	$("#AktuellesEndDatum").datepicker('destroy');
	$("#AktuellesEndDatum").datepicker({ date : new Date() });

	
	//console.log(getFiles('path/to/dir'));
	//console.log(checkForAvailblePrnFiles("../log/"));
	console.log('TEST LOG 1');
	DWH_Click_Write('#$anzdaten(0)');
	readCSV(); 

});

ahmadkarim avatar Dec 05 '16 20:12 ahmadkarim