简体   繁体   中英

AnyTime Picker default values

How to manipulate values that are first generated by AnyTime Picker? For example, I have an input field with AnyTime on it. When I click on that field, it gets populated with current time, and I want it to populate next round hour.

Try changing these lines of anytime.js

//  Initialize the picker's date/time value.

        try
        {
          this.time = this.conv.parse(this.inp.val());
          this.offMin = this.conv.getUtcParseOffsetCaptured();
          this.offSI = this.conv.getUtcParseOffsetSubIndex();
        }
        catch ( e )
        {
          this.time = new Date();
        }

to

//  Initialize the picker's date/time value.

        try
        {
          this.time = this.conv.parse(this.inp.val());
          this.offMin = this.conv.getUtcParseOffsetCaptured();
          this.offSI = this.conv.getUtcParseOffsetSubIndex();
        }
        catch ( e )
        {
          this.time = new Date();
          this.time.setHours(this.time.getHours()+1,0,0,0);
        }

The picker uses the time in the field as the initial value, and only defaults to the current time if the field can't be parsed. The easiest way to initialize the picker is to fill the field with the start value you want, being sure that it's in the correct format.

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