0

How do I call the onBeforeShow event with mobiscroll?

$('#starttime').mobiscroll('setValue', value).time({
        theme: 'jqm',
        display: 'modal',
        mode: 'clickpick',
        stepMinute: 10,
        onBeforeShow:  
 });

I need to set the time right before it shows. If I try to do it on document ready the input field isn't ready yet with the value...

Edit

I tried:

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

            }
        });

but then I'm getting the error: 'value is not defined'...

redconservatory
  • 21,438
  • 40
  • 120
  • 189

1 Answers1

2

You have to provide a callback function.

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

Libert Piou Piou
  • 540
  • 5
  • 22
  • Thanks I was looking there but this didn't have a code sample...hm but how do I set the value of 'value' if I'm setting it in "onBeforeShow"?? – redconservatory Jan 12 '13 at 02:47
  • I have never used mobiscroll but you can try this : $('#starttime').mobiscroll('setValue', value) inside the callback function – Libert Piou Piou Jan 12 '13 at 03:00
  • 1
    You also can use the instance "inst" to set the value. http://docs.mobiscroll.com/23/mobiscroll-instance – Levi Kovacs Jan 12 '13 at 07:30