zpaulovics / datetimepicker-rails

A date and time picker for Twitter Bootstrap in Rails using Simple Form
MIT License
174 stars 80 forks source link

How to clone a datetimepicker input field #87

Open fjvalles opened 7 years ago

fjvalles commented 7 years ago

I have a form in rails with simple form, and I'm using the as: :datetime_picker option to display the datetime selector. I want to clone the input field because it is part of a nested attribute in the form.

I'm having trouble understanding how to do this, because according to the documentation I understand that I have to do the following:

// Documentation says: Note All functions are accessed via the data attribute e.g. $('#datetimepicker').data("DateTimePicker").FUNCTION()

$('#datetimepicker1').data('DateTimePicker').destroy(); // Clone the input $('#datetimepicker1').datetimepicker();

The problem is that the .data('DateTimePicker') makes no sense to me because there is no DateTimePicker data attribute.

I would really appreciate some help with this, Thanks