Edgewall Software

Changes between Version 64 and Version 65 of GenshiTutorial


Ignore:
Timestamp:
Sep 1, 2007, 1:07:14 AM (17 years ago)
Author:
cmlenz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GenshiTutorial

    v64 v65  
    11131113To 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.”
    11141114
    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).
    11161116
    11171117We'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!
     
    11701170}}}
    11711171
    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.
     1172We'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.
    11731173
    11741174Add a template called `_comment.html` to the `geddit/templates` directory, and insert the following lines: