Open icetinturkey opened 4 years ago
You need to get a reference to the schedule i.e have var schedule
at the start on main.js and then near the end of function ScheduleTemplate( element )
save it as schedule = this;
Then from your button you would call the following:
//remove the loaded class
Util.removeClass(schedule.element, 'js-schedule-loaded');
//reinitialize the schedule
schedule.initSchedule();
Hope that helps. Just worked this out myself the other day.
Hello, I have the same issue, the elements are all placed at 07:30 when I want to load some :
<li class="cd-schedule__event">
<a data-start="15:00" data-end="15:30" data-content="event-rowing-workout" data-event="event-2" href="#0">
<em class="cd-schedule__name">013840</em>
</a>
</li>
inside my elements :
<ul id="friday"></ul>
using
document.getElementById('friday').innerHTML += html_str;
I tried what you advised, and declared the schedule var this way :
var schedule;
(function() {
// Schedule Template - by CodyHouse.co
function ScheduleTemplate( element ) {
this.element = element;
this.timelineItems = this.element.getElementsByClassName('cd-schedule__timeline')[0].getElementsByTagName('li');
this.timelineStart = getScheduleTimestamp(this.timelineItems[0].textContent);
this.timelineUnitDuration = getScheduleTimestamp(this.timelineItems[1].textContent) - getScheduleTimestamp(this.timelineItems[0].textContent);
this.topInfoElement = this.element.getElementsByClassName('cd-schedule__top-info')[0];
this.singleEvents = this.element.getElementsByClassName('cd-schedule__event');
this.modal = this.element.getElementsByClassName('cd-schedule-modal')[0];
this.modalHeader = this.element.getElementsByClassName('cd-schedule-modal__header')[0];
this.modalHeaderBg = this.element.getElementsByClassName('cd-schedule-modal__header-bg')[0];
this.modalBody = this.element.getElementsByClassName('cd-schedule-modal__body')[0];
this.modalBodyBg = this.element.getElementsByClassName('cd-schedule-modal__body-bg')[0];
this.modalClose = this.modal.getElementsByClassName('cd-schedule-modal__close')[0];
this.modalDate = this.modal.getElementsByClassName('cd-schedule-modal__date')[0];
this.modalEventName = this.modal.getElementsByClassName('cd-schedule-modal__name')[0];
this.coverLayer = this.element.getElementsByClassName('cd-schedule__cover-layer')[0];
this.modalMaxWidth = 800;
this.modalMaxHeight = 480;
this.animating = false;
this.supportAnimation = Util.cssSupports('transition');
this.initSchedule();
schedule = this;
};
...
}());
<AND HERE ARE MY FUNCTIONS TO LOAD SOME EVENTS WHERE I TRIED TO CALL schedule.scheduleReset(); AT THE END>
Thank you very much for your help
Hi, I'm adding new event with javascript. I'm using code like "document.getElementById("ul-sunday").innerHTML+=..." in onclick event. But new events not placing right space on table. So how can re-init schedule ?
Sorry for bad english, thanks in advance.