Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/435.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Mobiscroll onBeforeShow,设置值_Javascript_Jquery_Mobiscroll - Fatal编程技术网

Javascript Mobiscroll onBeforeShow,设置值

Javascript Mobiscroll onBeforeShow,设置值,javascript,jquery,mobiscroll,Javascript,Jquery,Mobiscroll,如何使用mobiscroll调用onBeforeShow事件 $('#starttime').mobiscroll('setValue', value).time({ theme: 'jqm', display: 'modal', mode: 'clickpick', stepMinute: 10, onBeforeShow: }); 我需要在它出现之前把时间调好。如果我尝试在文档就绪时执行此操作,则输入字段

如何使用mobiscroll调用onBeforeShow事件

$('#starttime').mobiscroll('setValue', value).time({
        theme: 'jqm',
        display: 'modal',
        mode: 'clickpick',
        stepMinute: 10,
        onBeforeShow:  
 });
我需要在它出现之前把时间调好。如果我尝试在文档就绪时执行此操作,则输入字段尚未就绪,其值为

编辑

我试过:

$('#starttime').mobiscroll('setValue', value).time({
        theme: 'jqm',
        display: 'modal',
        mode: 'clickpick',
        stepMinute: 10,
        onBeforeShow: function(html, inst) {
            start = $('#starttime').val();
            var a = moment();
            var value = a.format('h:mm A');

            }
        });

但是我得到了一个错误:“值未定义”…

您必须提供一个回调函数

$('#starttime').mobiscroll('setValue', value).time({
        theme: 'jqm',
        display: 'modal',
        mode: 'clickpick',
        stepMinute: 10,
        onBeforeShow: function (html, inst) {
            //Gets called before the scroller appears. The function receives the jQuery object containing the generated html and the scroller instance as parameters
        }
 });

谢谢,我正在查看,但这没有代码示例……嗯,但是如果我在“onBeforeShow”中设置“value”,我该如何设置它的值?我从未使用过mobiscroll,但您可以尝试以下方法:$(“#starttime”)。mobiscroll('setValue',value)在回调函数中您还可以使用实例“inst”来设置值。