views:

168

answers:

0

I'm trying to design reusable calendar with JS. I've done the easy part. Now's turn to add (display) entries in it.

If I'd be on server side I would use something like

classEntryBase
  entries = array();

  func addStuff(...)
  {
    ... this.entries[year][month][day] = array(link, linkText, entryText)
  }

  func getStuff(...)
  {
    ... return this.entries[year][month][day];
  }

myEntries extends classEntryBase
  func init
     loop through entries located somewhere
     {
       this.addStuff(...)
     }

entries = new myEntries(...)
entries.init();

c = new fooCalendar(entries);
c.render();

and fooCalendar has

loop through days
{
  entry = entries.getStuff(year, month, day);
  this.addToCell(entry);
}

But with JS you can just render this "stupid calendar" which is not aware of anything and add entries to it with DOM. Would this be more flexible and is there some complications?