Bước tiếp theo là xây dựng những ngày lịch thực tế. Một số bước cần phải được hoàn thành cho việc này để làm việc: 1. 2. Tạo một danh sách không có thứ tự mới. Thiết lập một vòng lặp (với một truy cập lặp đi lặp lại, truy cập ngày lịch, ngày hôm nay, và | CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY removeevent function Removes any event with the class active .active .fadeOut slow function this .remove . deserialize function str . urldecode function str . Modifying the Form Submission Handler to Remove Deleted Events To remove events after they are deleted add a new variable called remove to the form submission event handler. This will store a boolean value that tells the script whether to remove an event. By default this value will be set to false which means the event should not be removed. The only condition under which an event should be removed is if the Yes Delete It button is clicked from the confirmation dialog. Add a check for this text in the Submit button and set remove to true if a match is made. Inside the success handler set up a conditional that checks whether remove is true and fires if it is. Finally to prevent empty elements from being added to the calendar modify the conditional that fires to ensure that remove is false before executing. You can make these changes by adding the code shown in bold Edits events without reloading .edit-form input type submit .live click function event Prevents the default form action from executing Serializes the form data for use with .ajax var formData this .parents form .serialize Stores the value of the submit button submitVal this .val Determines if the event should be removed remove false If this is the deletion form appends an action if this .attr name confirm_delete Adds necessary info to the query string formData action confirm_delete confirm_delete submitVal If the event is really being deleted sets 305 CHAPTER 8 EDITING THE CALENDAR WITH AJAX AND JQUERY a flag to remove it from the markup if submitVal Yes Delete It remove true Sends the data to the processing file .ajax type POST url processFile data formData success function data If this is a deleted event removes it from the markup if remove true r .