jQuery mobile calendar with 3-state day colours

Viewed 8068

I am looking at creating an event and reservation system.

I found the Stack Overflow question jQuery - Mobile date picker control which shows jquery-mobile-datebox and jQuery-Mobile-Themed-DatePicker.

I want to display a calendar where certain dates I get from the server are

  1. available
  2. not available
  3. reserved

When a reserved or available date is touched, I want to show times - there can be more than one time per day. The user can then click on a time to reserve it which would hit off an Ajax request.

jQuery UI datepicker, for example, has

 onSelect: function(date, inst) {

From what I can see in the above pickers, what I need is not readily available. Before I start hacking them myself:

  1. Which one would lend itself best to what I want?
  2. Are there perhaps better ones out there that already serve my needs?

UPDATE:

Firebug gave me

<div class="ui-datebox-griddate ui-corner-all ui-btn-up-e" data-date="25" data-theme="e">25</div>

where ui-btn-up-e can be changed from a - e.

Now I need to find out if data-theme also needs to be changed

 $('.ui-datebox-griddate').click(function () {
   alert($(this).attr("class"));
 }

What is the nicest way to toggle through three of the classes and save the state each time?

 $('.ui-datebox-griddate').toggle(
   function () {
     $(this).????? // change ui-btn-up-? to ui-btn-up-a
     $.get(...)
  },
   function () {
     $(this).????? // change ui-btn-up-a to ui-btn-up-b
     $.get(...)
  },
   function () {
     $(this).????? // change ui-btn-up-b to ui-btn-up-c
     $.get(...)
  }
);

UPDATE: NOTE: When I click, the calendar change the date, reloading the calendar completely. Perhaps I need to stop that :(

2 Answers
Related