TAILIEUCHUNG - Tương tác giữa PHP và jQuery - part 20

CHAPTER 5 ■ ADD CONTROLS TO CREATE, EDIT, AND DELETE EVENTS Generating a Delete Button To start, add a Delete button to the full view edit controls by modifying _adminEntryOptions() in the Calendar class with the code shown in bold: /** * Generates edit and delete options for a given event ID * * @param int $id the event ID to generate options for * @return string the markup for the edit/delete options */ private function _adminEntryOptions($id) { return ADMIN_OPTIONS; } This adds a button that sends the. | CHAPTER 5 ADD CONTROLS TO CREATE EDIT AND DELETE EVENTS Generating a Delete Button To start add a Delete button to the full view edit controls by modifying _adminEntryOptions in the Calendar class with the code shown in bold Generates edit and delete options for a given event ID @param int id the event ID to generate options for @return string the markup for the edit delete options private function _adminEntryOptions id return ADMIN_OPTIONS div class admin-options form action method post p input type submit name edit_event value Edit This Event input type hidden name event_id value id p form form action method post P input type submit name delete_event value Delete This Event input type hidden name event id value id p form div -- end .admin-options -- ADMIN_OPTIONS This adds a button that sends the user to a yet-to-be-created confirmation page called which you ll build later in this section. After saving the preceding changes you will see both edit and delete options when viewing a full event description see Figure 5-7 . 191 CHAPTER 5 ADD CONTROLS TO CREATE EDIT AND DELETE EVENTS Figure 5-7. The Delete button as it appears on the full event view Creating a Method to Require Confirmation When a user clicks the Delete button he is sent to a confirmation page that contains a form to make sure he really wants to delete the event. That form will be generated by a new public method in the Calendar class called confirmDelete . This method confirms that an event should be deleted by performing the following actions 1. Checks if the confirmation form was submitted and a valid token was passed. If so go to Step 2. If not go to Step 3. 2. Checks whether the button clicked was the Confirmation button. If so it deletes the event. If not it sends the user back out to the main calendar view. 3. It loads the event data and displays the confirmation form. You accomplish the preceding steps by adding the new method shown in bold to the .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.