mobiscroll

Mobiscroll clear button


I would like to implement a clear button showed on popup in mobiscroll date picker There is an option to use button3, however I'm not able to clear the input and hide the scroller.

jQuery(this).mobiscroll({
        preset: 'date',
        theme:'ios',
        button3Text:'clear',
        button3: function(input, inst){
            jQuery(this).val();
            inst.close();
        }})

I was trying use the input and inst parameter from function. Unfortunately I'm not able to make it work.

Could you plese help?

Thanks Lucas


Solution

  • I already solve the problem. I couldn't get the instance but when I save the object first

     var thisPicker = jQuery(this); 
    

    and on button3 get the instance,

    var inst = thisPicker.mobiscroll('getInst');
    

    everything works fine.

    Whole code...

    // Date mobiscroll picker init
    jQuery(".datepicker").each(function (index, element) {
    
        var thisPicker = jQuery(this);
        jQuery(this).mobiscroll({
            preset: 'date',
            theme:'ios',
            display : 'bottom',
            button3Text:'X',
            button3: function(){
                var inst = thisPicker.mobiscroll('getInst');
                thisPicker.val('');
                inst.cancel();
    
            },
    
        });
    });