首页 > 解决方案 > Wickedpicker 总是显示当前时间

问题描述

所以我有我的 wickedpicker 的设置。这是设置

var options = {
            now: "12:35", //hh:mm 24 hour format only, defaults to current time 
            twentyFour: true, //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: 'Setting Jam', //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")
        };

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

然后我创建一个输入字段来存储时间数据

<input id="time_field" name="time_field" class="form-control time" placeholder="Time">

当我保存时,进入数据库的数据格式为“hh:mm”。然后我在编辑表单中再次将其显示为一个值。

<input id="time_field" name="time_field" class="form-control time" placeholder="Time" value="{{ $post->time }}">

但是,数据没有出现。数据仅显示默认数据,即 12:35。

每次我编辑数据时,时间字段总是显示 12:35,即使我已经根据数据库中的数据在输入中设置了值。但是,当我查看源页面时,来自数据库的数据出现在值输入部分。

然后我尝试使用jquery。当我从输入中检索数据值时,检索到的数据仍然是 12.35,这是 wickedpicker 的默认数据。

var time = $('.time').val();
console.log(time) // output 12:35

var time = $('.time').wickedpicker('time');
console.log(time) // output 12:35

如何从数据库中设置 wickedpicker 的输入字段中的时间?

标签: javascriptjquerylaravelwickedpicker

解决方案


推荐阅读