Live Comment Preview
I have now implemented live comment preview on the comment form. The preview is the same (Real) Live Textile Preview as seen on Binary Bonsai and described in one of Joen’s amazing articles.
The (Real) Live Textile Preview is not a plugin such as several of the other preview solutions, rather it is a number of javascripts and php scripts. The javascripts attach a function to the “key pressed” event of the comment field. Every time a key is pressed the text is passed to the php scripts through the magic of XMLHttpRequest (or AJAX) and returned as HTML. This returned batch of HTML is then shown to the user in the preview box.
This solution is a little more complex that the pure javascript or even simpler WordPress plugins. However, it has the clear advantage of being correct Textile. One simple example is links, if you write a link as the last part of a sentence, the period will in the javascript solutions be counted as part of the link, the (Real) Live Textile Preview shows this correctly. Having used Textile since I started using MovableType, this is a big plus for me.
As Joen pointed out, however, there are also disadvantages to this solution. Each keypress has the potential of sending a request to you server, if many people write comments at the same time, this can become a real burden. To be realistic though, the number of comments I receive are very small and the added load to the server will probably only serve to get it a bit more in shape.
I’ll run with it as is for now, try out my comments and tell me what you think.
May 10th, 2005 at 12:35 am
Have you seen this? Basicly it enables you to have markdown in your live comment previews. I find this a very usefull feature. If you are going to have live comment previews why not go the whole way?
Cron
May 10th, 2005 at 10:46 am
Seeing as I don’t even have markdown available for text on my site (I’d like a per post text formatting option as in MovableType), I don’t think markdown preview would do people any good. Ideally, a live preview should of course tap into the text formatting currently in place on the blog.
May 11th, 2005 at 1:14 pm
I think the best to do would be to set a timed interval to update the live preview (+ preview button press) and then also submit the comment using ajax, so you don’t have to wait for a reload of the whole page.
Of course, if you did that it’d probably look better if you’d put the preview above the commentbox, so it’d look like your preview would be automatically changed into a comment.
May 11th, 2005 at 1:20 pm
I actually like how it’s implemented here. Although a live comment preview which turns into the comment when submitted would be kinda cool. Only problem I can think of is if someone submits a comment while you are writing yours, then you won’t know since the page won’t update (as it does when you submit a comment now).
April 5th, 2007 at 2:04 pm
The site looks great! Thanks for all your help ( past, present and future!)