Pergunta

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

Foi útil?

Solução

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();

        },

    });
});

Outras dicas

Just found out that there is an option to enable "clear" button from within mobiscroll config:

http://docs.mobiscroll.com/2-15-1/mobiscroll-core#!opt-buttons

Buttons to display. Predefined buttons are: 'set', 'clear', 'cancel'. Custom buttons can also be specified:

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top