Materialize: Timepicker container option

Created on 28 Jun 2017  路  7Comments  路  Source: Dogfalo/materialize

Description

Materialize timepicker option container now working.

Example

$('.timepicker').pickatime({
 container: '#div'
  });

Solution

Is there any solution e.g. .appedTo('body') ?

help-wanted

Most helpful comment

Just made a pull request with the fix from @rharasim, it works just fine.

All 7 comments

The container option is not supported in Materialize. https://github.com/Dogfalo/materialize/blob/master/js/date_picker/picker.time.js

Oh sorry, thanks Daniel

This work

Open picker.time.js

Add default container option

    // Default options
    ClockPicker.DEFAULTS = {
        'default': '',      
        fromnow: 0,            
        donetext: 'Ok',      
        cleartext: 'Clear',
        canceltext: 'Cancel',
        autoclose: false,      
        ampmclickable: true, 
        darktheme: false,            
        twelvehour: true,     
        vibrate: true,          
    container: 'body'       // container  <--THIS IS ADDED
    };

Then change this line

// Append popover to body
   this.popover.insertAfter(this.input);

to this

// Append popover to body
    this.popover.appendTo(this.options.container);

Now you can use option container

$('.timepicker').pickatime({
    container: '#customdiv'
  });

You have to change materialize.min.js

Just CTRL+F this lines for better search:

This for appendTo
this.isAppended||(this.popover

and this for defaults

n.DEFAULTS={default:"

Seems solved then

Hi guys! The solution of @rharasim works well.. but I'm using Meteor and there's no way to change compiled packages. There's a possibility in the future to add the container feature in timepicker? I need timepicker inside modals with appendTo('body').

Thanks in advance and congratulations for this package!

Thank you so much @rharasim, it was exactly what i needed

Hi guys! I tried the solution of @rharasim but it doesn't fix my problem!
Can you please add the "container:'body'" feature to timepicker?
Thanks

Just made a pull request with the fix from @rharasim, it works just fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lpgeiger picture lpgeiger  路  3Comments

ericlormul picture ericlormul  路  3Comments

heshamelmasry77 picture heshamelmasry77  路  3Comments

artur99 picture artur99  路  3Comments

cope picture cope  路  3Comments