4

I currently using wickedpicker. I need to set the default time to two wickedpicker control when a user perform the button click operation. The timepickers.wickedpicker('time', 1) returns the time, but it wont provide any method to set the time.

Could you please tell me, how I can achieve the same?

j08691
  • 204,283
  • 31
  • 260
  • 272

1 Answers1

0

you could re-instantiate it.

Here are the options:-

var options = {
  now: "12:35", //hh:mm 24 hour format only, defaults to current time
  twentyFour: false, //Display 24 hour format, defaults to false
  upArrow: 'wickedpicker__controls__control-up', //The up arrow class selector to use, for custom CSS
  downArrow: 'wickedpicker__controls__control-down', //The down arrow class selector to use, for custom CSS
  close: 'wickedpicker__close', //The close class selector to use, for custom CSS
  hoverState: 'hover-state', //The hover state class to use, for custom CSS
  title: 'Timepicker', //The Wickedpicker's title,
  showSeconds: false, //Whether or not to show seconds,
  secondsInterval: 1, //Change interval for seconds, defaults to 1,
  minutesInterval: 1, //Change interval for minutes, defaults to 1
  beforeShow: null, //A function to be called before the Wickedpicker is shown
  show: null, //A function to be called when the Wickedpicker is shown
  clearable: false, //Make the picker's input clearable (has clickable "x")
};

$('.timepicker').wickedpicker(options);

so in your button click, call:-

$('button').click(function(){
    $('.timepicker').wickedpicker({ now: "12:35" });  
});
BenG
  • 14,826
  • 5
  • 45
  • 60
  • As I have two timepcier control on single page, so I tried to re-instantiate it by id i.e. ("#control-id-1").wickedpicker({ now: "12:35" }) but it didn't work out for me :( – Santosh Jagade Sep 08 '16 at 13:22
  • I'm looking to do the same. I have two controls and I need to set them individually. – Tom Sep 13 '16 at 08:42
  • 1
    @Tom give them different idenifiers. ie `$('#timepicker1').wickedpicker({ now: "12:35" });` and `$('#timepicker2').wickedpicker({ now: "9:00" });` – BenG Sep 13 '16 at 11:04
  • Thanks my question was slightly different so I asked here and got the answer needed. http://stackoverflow.com/questions/39467345/remove-jquery-from-element-and-reapply – Tom Sep 14 '16 at 07:52