Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i reset and re-init schedule ? #11

Open
icetinturkey opened this issue Oct 19, 2019 · 2 comments
Open

How can i reset and re-init schedule ? #11

icetinturkey opened this issue Oct 19, 2019 · 2 comments

Comments

@icetinturkey
Copy link

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.

  • @Dover8
    Copy link

    Dover8 commented Nov 11, 2019

    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.

    @oh-lily
    Copy link

    oh-lily commented Oct 27, 2020

    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

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants