using Bootstrap-datTimePicker with Backbone-forms

205 Views Asked by At

I'm addding a Custom editors in Backbone-forms, using bootstrap-dateTimePicker. However I get the error :

Uncaught TypeError: Cannot read property 'top' of undefined 

The custom field :

define(['jquery', 'underscore', 'backbone', 'backbone-forms', 'datetimepicker'],
    function($, _, Backbone, Datetimepicker){
    var Form = Backbone.Form;

    Form.editors.DateTimePicker = Form.editors.Text.extend({
    getValue: function() {
        var value = this.$el.val();
        return value;
    },

    render: function() {
        Form.editors.Text.prototype.render.apply(this, arguments);
        this.$el.datetimepicker({});
        return this;
    }
    });
});

I think is hase something to do with the missing class 'add-on'!

Added this line in render but nothing new

    `// this.$el.after('<span class="add-on"><i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span`>');

And please how can I customise the template for this field.

Thanks,

1

There are 1 best solutions below

0
evilcelery On

Haven't tested this but try adding a setTimeout() with s delay of 0 around the line that activates the date picker (in the render method).