0

I have a list of work orders that I am dropping into a Full Calendar. I need to have access to the work order's primary key so that I can update it's record in my MySQL database. So, I have simply added the work order's primary key to the title of the calendar event. Then, as I drop an event onto the calendar, the drop event parses the HTML and grabs the work order's primary key, storing it in the event itself for later use.

The problem is that this is ugly! I don't want the primary key on the event both because it's ugly and because it takes up too much space.

How do I include the primary key of my record in my list of items to be be added to the calendar, but not actually display these primary keys? I have tried adding a <div style="visibility:hidden"> to the list items, but that only hides the HTML when the item is in the list. As soon as I drop it onto the calendar, the <div> becomes visible again.

Any ideas?

1 Answer 1

1

There have been various answers to this. Myself, I just use event.id = primary key (assuming it is an int or reasonable string, see EvObj); then when responding to callbacks like eventClick(ev,...), for instance, you can retrieve it as ev.id and update your DB accordingly. That way you don't need to mess your events' titles or add strange hidden elements.

----- Addendum:

If using event.id causes conflicts with repeating events, the EvObj can also have custom properties, like event.dbid.

As for the other problem, to hide the dbid somewhere in the list of <div> that were to be dropped in the calendar, using jQuery data is a clean way to do it.

8
  • Thanks for your comment. After I posted this question, I had that same idea: use the event.id parameter to store my WO number. However, I'm worried that will bite me down the road. The docs say that " Different instances of repeating events should all have the same id". I read that as recurring events (same time slot/day every week, repeating). What if I want to schedule the same work order twice, in two different time slots, but they are not recurring? For example, I need to do half a work order on Tues. morning, and the rest on Thurs. after - any idea if this is doable? Thanks again :).
    – Garfonzo
    Commented Jan 9, 2013 at 16:58
  • My worries have been realized. Using the work order id as the event.id does not work. The problem comes when I have two appointments for the same work order. If I reschedule one, the other moves too. So, this, unfortunately, won't work.
    – Garfonzo
    Commented Jan 9, 2013 at 18:15
  • But you can also save your own properties in evObj, so you may as well use event.dbid.
    – MaxD
    Commented Jan 9, 2013 at 18:23
  • @ MaxD: True, I can, and I do. However, the list of events not yet in the calendar are simply <div> boxes. So, in order to get the work order ID into the calendar event, it needs to be present in the <div> somewhere. Thus, if it's in the div, it's going to show up on the calendar event - even though I parse the <div> to suck out the work order ID and store it in event.woID. I can't seem to set it up to hide the work order ID on the unscheduled items list, and keep it hidden on the calendar when it's initially dropped on the calendar.
    – Garfonzo
    Commented Jan 9, 2013 at 18:47
  • 1
    Have you tried adding jQuery data in your div? If these come from your db, you can even markup as data-dbid="str", and retrieve it as $(id).data("dbid").
    – MaxD
    Commented Jan 9, 2013 at 19:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.