Mobiscroll onBeforeShow,设置Value

时间:2013-01-12 02:09:13

标签: 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: function(html, inst) {
            start = $('#starttime').val();
            var a = moment();
            var value = a.format('h:mm A');

            }
        });

然后我收到错误:'值未定义'...

1 个答案:

答案 0 :(得分: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