Skip to content

Instantly share code, notes, and snippets.

@robinjfisher
Created April 26, 2010 18:48
Show Gist options
  • Save robinjfisher/379721 to your computer and use it in GitHub Desktop.
Save robinjfisher/379721 to your computer and use it in GitHub Desktop.
function grabBookings(date) {
$$(".booking").each(function(b) {
b.remove();
});
if (!$('ajax-loader')) {
$('bookings').insert("<img src='/images/ajax-loader.gif' id='ajax-loader' />");
}
new Ajax.Request(date.readAttribute("href"), {method:"get", evalJS:true, onSuccess:function(transport) {
var bookings = transport.responseJSON;
$('ajax-loader').remove();
bookings.each(function(b) {
var item = "<a href='/planes/" + b.plane_id +"/bookings/" + b.id + "'<div id='booking-" + b.id + "' class='booking' style='height:" + calculateBookingHeight(b.from,b.to) + "px;top:" + calculateBookingPosition(b.from,b.to) + "px;'><p><strong>From: </strong>" + formatTime(b.from) + "</p><p><strong>To: </strong>" + formatTime(b.to) + "</p></div></a>";
$('bookings').insert(item);
});
}});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment