简体   繁体   中英

events in AnyTime date picker

I want to fire a function when user clicks on any button under "Day Of the Month".

I found out the code for "Hour". But couldn't find the one for month.

The original problem -

I am updating an HTML span with the values selected in the AnyTime picker. I have set up earliest and latest limits. The former includes hours and minutes, the application is a scheduler, so I need only future dates, but not more than week.

I've added a function call on line 624 of anytime.js

This works great. For instance, at 5 PM, if a user selects 18th February with time as 12 AM (default), the span is updated properly. But, if he selects 15th Feb (that's today), "5 pm" gets automatically selected, being the earliest limit and the input is update properly. But there's no call to function (I don't expect one either, I haven't added anything for this).

What should I do to make sure that whenever such situation occurs, the function is called properly?

Thank you,all.

如果我正确理解了您的问题:处理一天中的每日新闻的功能是内联定义的,从anytime.js(未压缩的版本,您实际上应该对其进行修改)的第1579行开始,或者从第236行的第236行开始anytimec.js(压缩版本,很难弄清楚)。

I think you don't need to modify anything inside anytime.js plugin!

My workaround was to siply rely on datepicker's input " onChange " event, so everytime the input value is updated I get my custom event fired.

input.change( function () { // Update your formatted span here
    $("#my-span").html( this.value.length ? _formatVal(this.value) : "-" );
} );

And formatVal() could be a function to convert the original input format to a more fancy one to display at your span:

function _formatVal( val ) {
    return AnyTime.Converter( {format:'%a %e-%b-%Y'} ).format(
        AnyTime.Converter( {format:'%Y-%m-%d %H:%i:%s'} ).parse( val )
    )
}

Where format '%a %e-%b-%Y' is the one to display at your span , and format '%Y-%m-%d %H:%i:%s' is the original input value format (let's say a DATETIME MySQL field).

Works like a charm for me, hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM