0

如何使用 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');

            }
        });

但后来我收到错误消息:'值未定义'......

4

1 回答 1

2

你必须提供一个回调函数。

$('#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
        }
 });

http://docs.mobiscroll.com/23/mobiscroll-core

于 2013-01-12T02:31:44.163 回答