Tempus-dominus: Getting 'Uncaught TypeError: Cannot read property 'top' of undefined'

Created on 9 Oct 2015  路  3Comments  路  Source: Eonasdan/tempus-dominus

The plugin is working however I am getting 'Uncaught TypeError: Cannot read property 'top' of undefined'
I am using the latest version.

<div class="form-group">
    <div class="input-group date js-datetimepicker">
    <input type="text" class="form-control">
    </div>
</div>
$('.js-datetimepicker').datetimepicker({
     allowInputToggle: true,
     format:"MM/YYYY"
});

After inspecting the error it seems to be an issue with this line

if (offset.top + widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() &&

Most helpful comment

I've been running into the same issue. A quick fix seems to be to replace:

var position = (component || element).position(),
                    offset = (component || element).offset(),

with:

var position = element.position(),
                    offset = element.offset(),

on line 378 - 379. Not sure if it has any adverse effects, I haven't noticed any yet.

All 3 comments

I've been running into the same issue. A quick fix seems to be to replace:

var position = (component || element).position(),
                    offset = (component || element).offset(),

with:

var position = element.position(),
                    offset = element.offset(),

on line 378 - 379. Not sure if it has any adverse effects, I haven't noticed any yet.

Hi, If anyone still gets this

on the OP he has this:

<div class="form-group">
    <div class="input-group date js-datetimepicker">
    <input type="text" class="form-control">
    </div>
</div>

If changed to this no error appear, this should be the guidelines of http://eonasdan.github.io/bootstrap-datetimepicker/#no-icon-input-field-only

<div class="form-group">
  <div class="input-group date ">
    <input type="text" class="form-control js-datetimepicker">
  </div>
</div>

This is how I got it to work. The input element has to be wrapped with a div with position: relative

<div style="position: relative">
    <input class="form-control" type="text" data-datetimepicker>
</div>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

vogtdominikgit picture vogtdominikgit  路  3Comments

miraclebg picture miraclebg  路  3Comments

illudens picture illudens  路  4Comments

sjvisschers picture sjvisschers  路  5Comments

thw0rted picture thw0rted  路  5Comments