02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

290<br />

CHAPTER 8 ■ EDITING THE CALENDAR WITH AJAX AND JQUERY<br />

Figure 8-4. An event loaded immediately after creation<br />

Editing Events in a Modal Window<br />

In its current state, your app is only a short ways away from allowing users to edit events from the modal<br />

window, as well. The existing click event h<strong>and</strong>ler for loading the event creation form will also work for<br />

event editing with only a little modification.<br />

To start, exp<strong>and</strong> the selector to include any element with a class admin; you can accomplish this <strong>by</strong><br />

including the following bold code:<br />

// Displays the edit form as a modal window<br />

$(".admin-options form,.admin").live("click", function(event){<br />

// Prevents the form from submitting<br />

event.preventDefault();<br />

// Loads the action for the processing file

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!