Zallist / TimeScheduler

A simple JavaScript Timeline Scheduler library
119 stars 48 forks source link

Any idea how this would work with knockout.js? #10

Open asleg opened 9 years ago

asleg commented 9 years ago

Hi and thank for a brilliant piece of sw. I´d like to utilise this together with knockout. Say I´ve got a list of task that I can update either in the calendar view or the list view. I´d like to sett task title, subtitle, responsible, duration etc. I also liked the calendar to respond to new tasks created in the list. Any thoughts on this?

Zallist commented 9 years ago

Since this is almost entirely JavaScript, you would have to "subscribe" to your array in Knockout, then trigger a calendar update on change. The calendar Get function would need to be changed to pull from the array.

As an aside, this library will break for a day or 2 over the next week because of Daylight Savings Time. This is only a frontend issue, but I don't have time to fix it for a while. On 23 Oct 2014 21:07, "Asle" notifications@github.com wrote:

Hi and thank for a brilliant piece of sw. I´d like to utilise this together with knockout. Say I´ve got a list of task that I can update either in the calendar view or the list view. I´d like to sett task title, subtitle, responsible, duration etc. I also liked the calendar to respond to new tasks created in the list. Any thoughts on this?

— Reply to this email directly or view it on GitHub https://github.com/Zallist/TimeScheduler/issues/10.

asleg commented 9 years ago

Thanks for your quick answer, Zallist.

I guess by the Get function you mean the Calendar. GetSections() ?

I´ll make Items an observableArray in my view model like this: ... var self = this; self.Items = ko.observableArray(); // fill sell.Items here... ... But wouldn´t I need to write a ko.bindinghandler to Calendar as well? Or to TimeScheduler?

Something like the solution here: http://www.codeproject.com/Tips/780329/Bootstrap-datepicker-and-Knockout-model-binding

?

Zallist commented 9 years ago

No, you would add a Subscribe to your ObservableArray, which would then trigger an event whenever the array changed. The scheduler will be set up so that the Get events (sections and items) pulled data from your ObservableArrays. You would call TimeScheduler.FillSections or TimeScheduler.FillSchedule. On 24 Oct 2014 09:42, "Asle" notifications@github.com wrote:

Thanks for your quick answer, Zallist.

I guess by the Get function you mean the Calendar. GetSections() ?

I´ll make Items an observableArray in my view model like this: ... var self = this; self.Items = ko.observableArray(); // fill sell.Items here... ... But wouldn´t I need to write a ko.bindinghandler to Calendar as well? Or to TimeScheduler?

Something like the solution here: http://www.codeproject.com/Tips/780329/Bootstrap-datepicker-and-Knockout-model-binding

?

— Reply to this email directly or view it on GitHub https://github.com/Zallist/TimeScheduler/issues/10#issuecomment-60359897 .

asleg commented 9 years ago

So something like: self.Items = ko.observableArray() //self.Items.push(something)

self.Items.subscribe( function(item) {
    TimeScheduler.FillSections();
});

?

Does TimeSchedular allow editing today, i.e. would this work: item.name = ´

<input data-bind=value: title" />
subtitle something...
´

where title is an observable?