bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

Unknown error in calendar function... #167

Open ThomasCelen opened 8 years ago

ThomasCelen commented 8 years ago

Hi,

I'm trying to implement the datetimepicker, rome-plugin in my rails application but I'm receiving an unkown error. (please know this is the first time that I'm implementing such a plugin) so it might be a basic error.

My view:

<% @properties.where(:location_id => l.id).each do | p | %>
    <tbody>
        <tr>
            ...//removed some other code here to go to the problem //..
            <td data-title="Meeting Slot">
                <input id='input' class='input' />
            <script>rome(input);</script>
            </td>
        </tr>
    </tbody>
<% end %>

The error I'm receiving: Uncaught TypeError: o.appendTo.appendChild is not a function via: calendar.js:67

Line 67 is:

api.back = subtractMonth; This refers to line 1224 of the rome.standalone.js file

What I've done so far:

  1. load Moment.js via the 'momentjs-rails' gem
  2. Create a file rome.standalone.js in my assets/javascript folder with a copy paste of the rome;standalone.js file which can be found on the github page.
  3. added the input and script file on my view.

Anyone who can help me figure out what is wrong?

Many thanks, T

UPDATE: If I paste my view code to the top of the page, outside the table, it gives no error but still doesn't load the datetimepicker...

BastianMorawsky commented 8 years ago

I have the same problem. No solution so far.

dodumosu commented 8 years ago

I'm not sure (yet) how @bevacqua was loading his DOM elements, but you need to pass in a DOM element for the calendar to work. once i changed the argument to rome() to the result of a document.getElementById() call, the calendar worked fine.

dodumosu commented 8 years ago

to clarify: var input = document.getElementById('myinput'); rome(input); // works fine.