robmonie / jquery-week-calendar

Now actively maintained in the following fork - https://github.com/themouette/jquery-week-calendar
388 stars 391 forks source link

Set readonly flag based on data #6

Open chimericdream opened 14 years ago

chimericdream commented 14 years ago

I have a working implementation of the calendar pulling from several different data sets. However, I need to be able to set the readonly flag based on which data set is being displayed. Currently the calendar is either completely read only, completely writable, or individual events can be read only.

Anyone get this feature working? I've spent the past 8 hours at work trying to do only this.

Thanks in advance.

Maraumax commented 14 years ago

It is a very good idea and I would be interested also.

graemeworthy commented 14 years ago

I don't know if you're still having a problem with this, but I've found it useful, when combining datasets, to add a field into the data regarding what dataset is being polled.

for example you can add properties to the event on your server

{"id":1, "start":"2009-05-10T13:15:00.000+10:00", "end":"2009-05-10T14:15:00.000+10:00", "title":"Lunch with Mike", "dataset":"thereadonlyone", "will_there_be_snacks?":"totally"}


these properties can be used to set up the readonly value as part of the 'eventrender' function:

    eventRender : function(calEvent, $event) {
        if(calEvent.dataset == "thereadonlyone"){
                                  calEvent.readOnly = true;
        };
        if(calEvent["will_there_be_snacks?"] == "totally"){
                                  $event.addClass("there_will_be_snacks")
        };

    },