Closed jclusso closed 8 years ago
I ended up doing this... not sure if it's the best way to go about the problem though. Btw, ignore the tabbing. It's coffeescript and It's just pasting in a little weird
if window.calendar != undefined
$('.daterange.daterange--double').children().remove()
window.calendar = new Calendar(
element: $('.daterange--double')
earliest_date: moment(@createdAt)
latest_date: @loadEndDate()
start_date: @loadStartDate()
end_date: @loadEndDate()
callback: (@start_date, @end_date) =>
@updateChart(@start_date, @end_date)
)
@jclusso What I typically do is test for the existence of the calendar object and if it doesn't exist I create it. So rather then destroy it every time you ensure you only create it once. Either way though sounds like you got it working.
Well checking if it existed stopped it from making a new one, but I think because the events are not bound to the document it doesn't work anymore after a page change.
I'm trying to use turbolinks in our application and I can't figure out how to make it so I don't get multiple calendar objects. Is there a way to destroy the calendar? I've tried doing like
The issue is the Calendar no longer works after I do that...