1 of 2
1
Ajax Comment Preview with jQuery
Posted: 02 December 2008 10:51 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  342
Joined  10-24-2007

Hey folks,

I know this one is not exactly EE, but I was wondering if anyone has used jquery ajax to display comment previews?  I was hoping to use it on a site, and wasn’t sure how to go about it.

Thanks!
Zac

 Signature 

About Zac Gordon | High School and College Web Development Teacher | @zgordon

Profile
 
 
Posted: 02 December 2008 11:10 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Avatar
Total Posts:  24
Joined  12-11-2007

You could have a look at this plugin:

http://rikrikrik.com/jquery/magicpreview/

 Signature 

Jedidiah Broadbent  |  Freelance Designer |  http://jedidiah.eu/

Profile
 
 
Posted: 02 December 2008 11:59 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  342
Joined  10-24-2007

Hey jedidiah,

A little different than what I had though, but that may work just fine!

Thanks

 Signature 

About Zac Gordon | High School and College Web Development Teacher | @zgordon

Profile
 
 
Posted: 02 December 2008 02:17 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1925
Joined  08-02-2006

I’m using MagicPreview on a site I’m working on right now and it works like a charm.

 Signature 

Deron Sizemore
==========
LogoGala | Kentucky Golfing
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 02 December 2008 02:19 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  342
Joined  10-24-2007

Yeah, I plugged it in and it’s working great!

 Signature 

About Zac Gordon | High School and College Web Development Teacher | @zgordon

Profile
 
 
Posted: 02 December 2008 03:59 PM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2312
Joined  05-13-2004
Jedidiah - 02 December 2008 11:10 AM

You could have a look at this plugin:

http://rikrikrik.com/jquery/magicpreview/

beautiful find - I have a use for this right now.

 Signature 

CreateSean Web Design | EE Forums 4 You ExpressionEngine forum customization
on twitter @createsean I am the poster formally known as The Linguist.

Profile
 
 
Posted: 02 December 2008 04:03 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Avatar
Total Posts:  24
Joined  12-11-2007
Zac G. - 02 December 2008 02:19 PM

Yeah, I plugged it in and it’s working great!

Glad it worked for you, it is a great little plugin.

 Signature 

Jedidiah Broadbent  |  Freelance Designer |  http://jedidiah.eu/

Profile
 
 
Posted: 02 December 2008 05:40 PM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1925
Joined  08-02-2006

Not sure if anyone has made any changes to the MagicPreview plugin like this or not, but what I’d like to do with it is like what John is doing here with his comment form: http://www.tyssendesign.com.au/articles/which-is-better-for-search-engines-plain-text-or-alt-attributes/

Once someone starts typing their name, their name shows up in the preview as well as “says…” How could I go about doing something similar to that? I’d rather have the additional text show up once someone starts typing rather than simply putting it straight into the HTML statically.

 Signature 

Deron Sizemore
==========
LogoGala | Kentucky Golfing
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 02 December 2008 06:57 PM   [ Ignore ]   [ # 8 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2039
Joined  09-16-2004

Have a look at the source code of that page, it calls a script called live-comment-preview.js, it looks like it’s some kind of wordpress plugin.

On a site I’m wrapping up now I used this jQuery technique but added Markdown formatting instead of HTML.

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 02 December 2008 07:13 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Avatar
Total Posts:  24
Joined  12-11-2007
Deron Sizemore - 02 December 2008 05:40 PM

Not sure if anyone has made any changes to the MagicPreview plugin like this or not, but what I’d like to do with it is like what John is doing here with his comment form: http://www.tyssendesign.com.au/articles/which-is-better-for-search-engines-plain-text-or-alt-attributes/

Once someone starts typing their name, their name shows up in the preview as well as “says…” How could I go about doing something similar to that? I’d rather have the additional text show up once someone starts typing rather than simply putting it straight into the HTML statically.


There is an option to call a function in the options either onBefore or onAfter

I’ve put a quick and nasty example that uses the onAfter up here
http://jedidiah.eu/code/javascript/magicpreview/

$(function () {
    
$('input:text, textarea').magicpreview('mp_', { 'onAfter': function (value) {
            
if(value){
                
$('#previewbox').fadeIn("slow");
            
}
      } }
);
          
});
 Signature 

Jedidiah Broadbent  |  Freelance Designer |  http://jedidiah.eu/

Profile
 
 
Posted: 02 December 2008 07:34 PM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1925
Joined  08-02-2006
e-man - 02 December 2008 06:57 PM

Have a look at the source code of that page, it calls a script called live-comment-preview.js, it looks like it’s some kind of wordpress plugin.

On a site I’m wrapping up now I used this jQuery technique but added Markdown formatting instead of HTML.

I’ve never seen that one before. I thought I had searched through the jQuery site pretty thoroughly too. I suppose not. wink

When you say you added Markdown formatting instead of HTML. Is that something done via jQuery?

 Signature 

Deron Sizemore
==========
LogoGala | Kentucky Golfing
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 02 December 2008 07:53 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2039
Joined  09-16-2004

@ jedidiah: seriously sweet this smile
@ deron: the markdown is a combination of the standard EE comment form, the jQuery in abovementioned article and Showdown to handle the Markdown formatting in the JS.
EE-code:

<h4>Live Comment Preview</h4>
<
div id="live-preview">
</
div><!-- #live-preview -->
<div id="comment_form_holder">
{exp:comment:form weblog="weblogged"}
<label for="comm_name">Name: <input type="text" name="name" value="{name}" size="50" id="comm_name" /></label>
<
label for="comm_email">Email: <input type="text" name="email" value="{email}" size="50" id="comm_email" /></label>
<
label for="comm_website">Website: <input type="text" name="url" value="{url}" size="50" id="comm_website" /></label>
<
label for="comm_content">Your comment: <span id="markdown">Use of <a href="http://daringfireball.net/projects/markdown/syntax" title="guide to markdown syntax">Markdown</a> allowed</span><textarea name="comment" cols="70" rows="10" id="comm_content">{comment}</textarea></label>
<
input type="submit" name="submit" value="Submit" />
{/exp:comment:form}

jQuery code:

// easy comment previewing + showdown for markdown parsing in preview
    
      
var $comment = '';
      $(
'#comm_content').keyup(function() {
        
var converter = new Showdown.converter();
        
$comment = $(this).val();
        
$comment = converter.makeHtml($comment);
        $(
'#live-preview').html($comment);
      
});

with, of course a call to the the showdown script in the head of your page:

<script src="{site_url}js/showdown.js" type="text/javascript"></script>

and, where you display the actual comment:

{exp:markdown}{comment}{/exp:markdown}
 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 02 December 2008 08:22 PM   [ Ignore ]   [ # 12 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3487
Joined  08-28-2003

How does using a jQuery “preview” differ from using EE’s built in preview?

 Signature 

grrramps
———
Honolulu, HI
———
Home | Old Hobby | New Hobby | Newer Hobby | Another update via CSS

Profile
 
 
Posted: 02 December 2008 08:26 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  2039
Joined  09-16-2004
RonnieMc - 02 December 2008 08:22 PM

How does using a jQuery “preview” differ from using EE’s built in preview?

LOL, EE has a built-in preview? smile

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 02 December 2008 08:43 PM   [ Ignore ]   [ # 14 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1925
Joined  08-02-2006
Jedidiah - 02 December 2008 07:13 PM
Deron Sizemore - 02 December 2008 05:40 PM

Not sure if anyone has made any changes to the MagicPreview plugin like this or not, but what I’d like to do with it is like what John is doing here with his comment form: http://www.tyssendesign.com.au/articles/which-is-better-for-search-engines-plain-text-or-alt-attributes/

Once someone starts typing their name, their name shows up in the preview as well as “says…” How could I go about doing something similar to that? I’d rather have the additional text show up once someone starts typing rather than simply putting it straight into the HTML statically.


There is an option to call a function in the options either onBefore or onAfter

I’ve put a quick and nasty example that uses the onAfter up here
http://jedidiah.eu/code/javascript/magicpreview/

$(function () {
    
$('input:text, textarea').magicpreview('mp_', { 'onAfter': function (value) {
            
if(value){
                
$('#previewbox').fadeIn("slow");
            
}
      } }
);
          
});

Nice!! Works like a charm even though I don’t fully understand how it works. wink *Runs to start reading his Learning jQuery book*

e-man - 02 December 2008 07:53 PM

@ jedidiah: seriously sweet this smile
@ deron: the markdown is a combination of the standard EE comment form, the jQuery in abovementioned article and Showdown to handle the Markdown formatting in the JS.
EE-code:

<h4>Live Comment Preview</h4>
<
div id="live-preview">
</
div><!-- #live-preview -->
<div id="comment_form_holder">
{exp:comment:form weblog="weblogged"}
<label for="comm_name">Name: <input type="text" name="name" value="{name}" size="50" id="comm_name" /></label>
<
label for="comm_email">Email: <input type="text" name="email" value="{email}" size="50" id="comm_email" /></label>
<
label for="comm_website">Website: <input type="text" name="url" value="{url}" size="50" id="comm_website" /></label>
<
label for="comm_content">Your comment: <span id="markdown">Use of <a href="http://daringfireball.net/projects/markdown/syntax" title="guide to markdown syntax">Markdown</a> allowed</span><textarea name="comment" cols="70" rows="10" id="comm_content">{comment}</textarea></label>
<
input type="submit" name="submit" value="Submit" />
{/exp:comment:form}

jQuery code:

// easy comment previewing + showdown for markdown parsing in preview
    
      
var $comment = '';
      $(
'#comm_content').keyup(function() {
        
var converter = new Showdown.converter();
        
$comment = $(this).val();
        
$comment = converter.makeHtml($comment);
        $(
'#live-preview').html($comment);
      
});

with, of course a call to the the showdown script in the head of your page:

<script src="{site_url}js/showdown.js" type="text/javascript"></script>

and, where you display the actual comment:

{exp:markdown}{comment}{/exp:markdown}

That’s awesome! Thanks for the preview of how it works with Markdown.

 Signature 

Deron Sizemore
==========
LogoGala | Kentucky Golfing
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 02 December 2008 09:39 PM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  855
Joined  11-07-2004
RonnieMc - 02 December 2008 08:22 PM

How does using a jQuery “preview” differ from using EE’s built in preview?

They’re referring to a live preview. So it shows you what your post will look like in real time, as you write it.

EE’s preview requires a form submit and a page refresh to display it.

 Signature 

Member: ExpressionEngine Pro Network: ePlaces Network Services

ePlaces Network Services

Profile
 
 
Posted: 02 December 2008 10:42 PM   [ Ignore ]   [ # 16 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3487
Joined  08-28-2003
JT Thompson - 02 December 2008 09:39 PM

They’re referring to a live preview. So it shows you what your post will look like in real time, as you write it.

EE’s preview requires a form submit and a page refresh to display it.

Got it. Looks very slick and sassy.

Just two more jQuery plugins and my web pages will be so heavy they’ll need to be delivered by the post office.

 Signature 

grrramps
———
Honolulu, HI
———
Home | Old Hobby | New Hobby | Newer Hobby | Another update via CSS

Profile
 
 
Posted: 03 December 2008 01:05 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  342
Joined  10-24-2007

Wow!  Thanks for all of the great options here… better go try some of them out smile

 Signature 

About Zac Gordon | High School and College Web Development Teacher | @zgordon

Profile
 
 
Posted: 03 December 2008 02:17 PM   [ Ignore ]   [ # 18 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3487
Joined  08-28-2003

I’ve tried three or four of these already. The one I like best is from Rockatee. Very easy installation, small script, painless, highly customizable via CSS.

 Signature 

grrramps
———
Honolulu, HI
———
Home | Old Hobby | New Hobby | Newer Hobby | Another update via CSS

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 02:47 PM
Total Registered Members: 119595 Total Logged-in Users: 99
Total Topics: 125822 Total Anonymous Users: 56
Total Replies: 662080 Total Guests: 472
Total Posts: 787902    
Members ( View Memberlist )