Javascript Mobiscroll onBeforeShow,设置值
如何使用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: }); 我需要在它出现之前把时间调好。如果我尝试在文档就绪时执行此操作,则输入字段
$('#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”来设置值。