04 May 2006

coComment and AJAX commenting

coComment cool button This should be a quick post for those that having problem with coComment, WordPress AJAX commenting, K2 with Live Commenting enable and probably others that are using AJAX goodies for submitting form.

After reading through coComment integrate page and cocomment.js, I found out that the culprit is the onSubmit event and it is the same event that triggers coComment when we submit the comment form. The current AJAX commenting code uses return false to stop a form from being submitted if there’s any error occur.

So basically if we want to use 2 onSubmit event, open comments.php and remove or delete return false; somewhere at the end of form tag (K2) right after parameters: Form.serialize(this)}); or in your AJAX comment JavaScript file. There’s probably a drawback (error indicator failed to work) but that should do it. Let me know if it’s working or not.

And yeah, if there’s any coComment staff reading this, please change my coComment blog title. Thank you in advance.

UPDATE: It seems that I need to reconfigure my coComment firefox extension preferences and untick ‘ignore unknown webpages (recommended)’ and manually set my blog Title since it does not automatically recognize my blog.

UPDATE 2: As far as I can tell, coComment recognize blog title that is using “-” and “»” but not k2 which uses “at” as title separator. Furthermore I remove my blog title when viewing single entry. Embedding the coComment WordPress code somewhere in your comment.php should force the variable to be properly inserted and set var cocomment_force to true (I think). No need to add cocomment.js.

PS: As far as I know, digg.com also suffers this same issue. And also coComment indeed does not work on WordPress.com in secure blogging mode (https).

24 Comments

  1. Zeo

    This comment should be submitted to my coComment conversation page.

  2. Thanks Zoe!

    I’ll let the db folks know about correcting the blog title. That change will probably have to wait until tomorrow, though.

  3. So does that mean that if I

    open comments.php and remove or delete return false; somewhere at the end of form tag (K2) right after parameters: Form.serialize(this)});

    then CoComment will work on K2 with the proper titles and everything?

    thanks

    Carl

  4. I see, this allows you to use cocomment and have Ajax enabled.

    Does not fix the title problem.

    Carl

  5. Zeo

    Carl, if you are talking about entry title do read UPDATE 2. If it’s regarding your blog title, then you have to ask coComment staff to update it for you.

  6. Hey zeo, thanks for info, my site can run the cocomments although there are some bugs.

  7. [...] First of all, many thanks to Safirul Aldredha with his insightful tip and hack on how to get cocomments to work on a comment system that has been integrated with Ajax.. [...]

  8. Testing coComment bookmarklet on non-embedding ajax-commenting blog…

  9. Ok, *that* works :-)

  10. @Zeo: your coComment blog title has been fixed.

  11. Zeo

    Thanks a lot Chris and team for fixing my coComment blog title :)

  12. malaysian있게 거만한

  13. Hi,Zeo,so it means that if I change my K2 template following the step,just del “return false;”which after “parameters: Form.serialize(this)});” of “comment.php”,coComment will work properly with AJAX commenting enabled?

    Well I followed this and everything looks fine:comment submiting without load the whole page,a popup window say that my comment has been sent to coComment while comment submitting.But my comment couldnt be shown unless I refresh the comment page.Furthermore,I cant find the comment on my conversations on coComment.

    So did I miss something?

  14. Zeo

    I have no idea. But this is what I use to force non-coCo user to use coComment without extension or bookmarklet.


    <!-- coComment integration -->
    <script type="text/javascript">
    var blogTool = "WordPress";
    var blogURL = "<?php echo get_option('siteurl'); ?>";
    var blogTitle = "<?php bloginfo('name'); ?>";
    var postURL = "<?php the_permalink() ?>";
    var postTitle = "<?php the_title(); ?>";
    <?php if ( $user_ID ) : ?>
    var commentAuthor = "<?php echo $user_identity; ?>";
    <?php else : ?>
    var commentAuthorFieldName = "author";
    <?php endif; ?>
    var commentAuthorLoggedIn = <?php if ( !$user_ID ) { echo "false"; }
    else { echo "true"; } ?>;
    var commentFormID = "commentform";
    var commentTextFieldName = "comment";
    var commentButtonName = "submit";
    var cocomment_force = false;
    </script>


    <script id="cocomment-fetchlet" trackAllComments="true" type="text/javascript" src="http://www.cocomment.com/js/cocomment.js"></script>
    <!-- End coComment integration -->

    I hope that they would do something with invalid trackAllComments=”true” attribute.

  15. [...] 之前 coComment 一直不支援 Ajax Comment,我曾在 coComment Forum 提出了這個問題,但一直都沒有得到解決方法,所以我一直都半放棄 coComment,只安裝了 coComment Firefox extension 來儲存我在其他 blogs 的留言便算,但剛從 ZEO 中得知怎樣解決這個問題,原來方法很簡單,只而刪除 Ajax form å…§çš„ “return false;” 這句便可,雖然有一個副作用,就是當留言出問題時不能顯示 error indicator,但可以支援 Ajax comment,我都不計較了。 [...]

  16. I can see the coComment field,I just cant send my comment to my coComment conversation,when I submitted,everything seems ok,a popup window show that my comment has been sent,but my conversation didnt receive anything.

  17. [...] 其实这是因为coComment和AJAX回复冲突造成的,现在在Zeo的BLOG上已经提供了解决的方法。编辑K2主题下的comment.php,查找return false;去掉comment form中在Form.serialize(this)});后的那个return false;(应该是第二个return false)就可以了。 [...]

  18. Zeo

    This is actually not the ‘best practice’ to handle this. It would be much easier if someone could gone through the compressed cocomment.js and tell me what they put inside the onSubmit handler :P

  19. What exactly is it, that you have in mind, Zeo? Basically, my current code overloads an exsiting onsubmit handler with one that first sends the comment to cocomment.com before the original onsubmit handler is called. What would you like to know and what is your plan?

    Chris

  20. [...] 另外还可以参考Zeo的原文:coComment and AJAX commenting。 AJAX COMMENTING, coComment, Design, 随笔, 设计 [...]

  21. Be careful where you put that cocomment code in your comments.php, or when you ping a site with a trackback you will send all of that with it.

    Thanks for the work around on the ajax comments. The main reason I stopped using mine is because of coco.

  22. Great, works for me!

  23. [...] 這次最重要是想說現在的 Ajax Comment 都是不支援 coComment 的,其實 Zeo 之前已經談過解決辦法,但不論是 K2 或是 Ajax Comment Plugin 都沒有把這修正收納在內,因為 Zeo 說會有一個小的後遺症就是當有錯誤出現時會不能顯示 error indicator,但是現在的 K2 好像沒有這個 image file,所以不肯定這個後遺症是否還存在。 [...]

  24. But now does it work?