Changes between Version 64 and Version 65 of GenshiTutorial
- Timestamp:
- Sep 1, 2007, 1:07:14 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GenshiTutorial
v64 v65 1113 1113 To demonstrate how you'd use Genshi in a project that uses AJAX, let's enhance the Geddit commenting feature to use AJAX. We'll implement this in such a way that the current way comments work remains available, to serve those who don't have Javascript available, and also just to be good web citizens. That approach to using funky new techniques is often referred to as “unobtrusive Javascript”, and what it provides is “graceful degradation.” 1114 1114 1115 '''Note''': technically, what we'll be doing here isn't AJAX in the literal sense, because we'll not being transmitting XML. Instead, we'll respond with simple HTML fragment , a technique that is sometimes referred to as “AJAH”.1115 '''Note''': technically, what we'll be doing here isn't AJAX in the literal sense, because we'll not being transmitting XML. Instead, we'll respond with simple HTML fragments, a technique that is sometimes referred to as “AJAH” (“H” as in HTML). 1116 1116 1117 1117 We'll go about this in the following way: on a link submission detail page, the “Add comment” button will now load the comment form into the current page, instead of going to the dedicated comment submission page. When the user clicks the “Cancel” button, we simply remove the form from the page. On the other hand, if the user clicks the ”Submit” button, we validate the entry, and if it's okay, we remove the form and load the new comment into the list on the page. That means that the user never leaves or reloads the link submission detail page in the process! … … 1170 1170 }}} 1171 1171 1172 We'll also need to make the display of an individual comment available as an HTML fragment, so let's factor it out into a separate template file , too.1172 We'll also need to make the display of an individual comment available as an HTML fragment, so let's factor it out into a separate template file as well. 1173 1173 1174 1174 Add a template called `_comment.html` to the `geddit/templates` directory, and insert the following lines: