WordPress.org

Ready to get started?Download WordPress

Forums

Inline Ajax Comments
[resolved] Doesnt work when multiple commentforms on one page... (14 posts)

  1. DomDom2013
    Member
    Posted 1 year ago #

    Hey,

    great plugin. Just one problem: I use it more than once on a page, and it doesnt work there...

    Go to http://www.outfitya.com/de/, create 3 or more test outfits and then go to "meine outfitfits". U see then the comments load everywhere. just when submitting the a comment on the second or third comment field, it doesn't load the newest comment into the correct spot...

    I think it has to do with this code:

    $.ajax({
                data: data,
                global: false,
                success: function( msg ){
                    inline_comments_ajax_load_template({
                        "target_div": "#inline_comments_ajax_target",
                        "template": $( '#inline_comments_ajax_handle' ).attr( 'data-template' ),
                        "post_id": $( '#inline_comments_ajax_handle' ).attr( 'data-post_id' ),
                        "security": $( '#inline_comments_nonce' ).val()
                    }, false );
                    $('textarea').val('');
                    $this.css('opacity','1');
                }

    "target_div": "#inline_comments_ajax_target", exists more than once on my page... So thats why it cannot append the new comment correctly.
    Maybe something like
    "target_div": $(this).closest()."#inline_comments_ajax_target", would work...

    Would love see it working for multiple comment section on one page...

    Greets,
    Dom

    http://wordpress.org/extend/plugins/inline-ajax-comments/

  2. Zane Matthew
    Member
    Plugin Author

    Posted 11 months ago #

    Hi Dom,

    Can you send me a direct link to an outfit? I'm in the process of updating this plugin, I have the following coming: https://github.com/zanematthew/inline-ajax-comments/issues?state=closed

  3. Matt McFarland
    Member
    Posted 10 months ago #

    Hi guys,

    I think that this could be fixed better with just naming the #comment id uniquely, easiest way is to make it uniform with the post.

    So if it is a comment on post ID 43, then you could have #comment_43 be the selector instead of comment.

    This can easily be done:

    <div id="comment_<?php Print get_the_ID ?>"

  4. Matt McFarland
    Member
    Posted 10 months ago #

    Forgot that get_the_ID returns an INT and we want a STRING..

    anyway, it could be done similar to this:

    <!-- Get the post id the comment belongs to and change it from int to string "comment_POSTID" -->
      <?php $cp_id = get_the_ID();?>
      <?php $comment_post_id = "comment_" . strval($cp_id); ?>
    
      <!-- The comments container is now unique -->
      <div class="inline-comments-container" name="<?php echo comment_post_id ?>">
  5. Matt McFarland
    Member
    Posted 10 months ago #

  6. Matt McFarland
    Member
    Posted 10 months ago #

    The problem is that the target needs a unique identifier, I'll show a fix here shortly.

  7. Zane Matthew
    Member
    Plugin Author

    Posted 10 months ago #

    Matt,

    Adding it a unique ID makes sense, in your current master branch here, https://github.com/MattMcFarland/inline-ajax-comments/blob/master/templates/comments.php#L26 your adding it to the class. It would be be better to do it as you have above, since the class "inline-comments-container" shouldn't be unique.

  8. Matt McFarland
    Member
    Posted 10 months ago #

    Hi zane, I agree.

    Please see my latest update on github (dev branch) I'm using id instead of class to keep stylesheet intact.

    Also, you can't use document.submit for multiple posts working

    So far I have multiple comment postings reading perfectly fine now and the more / less buttons also work according to plan.

    Now to rework the the ajax submit and it'll be 100% finished.

  9. Matt McFarland
    Member
    Posted 10 months ago #

  10. Matt McFarland
    Member
    Posted 10 months ago #

    you can see it working (except ajax submit) on http://www.hvac-hacks.com

  11. Matt McFarland
    Member
    Posted 10 months ago #

    Ok.. So I now have it working (sorta) So far put about 8 hours into this heh.

    Problem 1: comments ajax handle, 'data-template' is now returning undefined.

    Problem 2: Had to disable wp noonce in template-tags to get it to work.

    Can't seem to find a fix for these issues can you help? It's almost 100% done!

    Please look at my github dev branch, the latest (with problems) is there:
    https://github.com/MattMcFarland/inline-ajax-comments/compare/dev?expand=1

  12. Matt McFarland
    Member
    Posted 10 months ago #

    I have it fully working

    My changes are below:
    = 1.2.4.5m =
    * Fix: unique target id's added
    * Fix: ajax loading multiple comment lists
    * Fix: ajax submit multiple comment lists
    * Fix: more/less buttons work on multiple comment lists
    * Enhanced: swapped more/less buttons with graphics
    * Tweak: More/Less stays on the same line as the input box at smallest browser widths for responsiveness

    TODO: implement multi-listing wp_nonce functionality.

    = 1.2.4.3m =
    * Fix: Allow for use ANYWHERE

    = 1.2.4.2m =
    * Fix: Changed "user_nicename" (deprecated) to "display_name"

    = 1.2.4m =
    * Tweak: Changed min-height from 17 to 32

    You can download it here:
    https://github.com/MattMcFarland/inline-ajax-comments

  13. Zane Matthew
    Member
    Plugin Author

    Posted 9 months ago #

    Matt,

    Thanks for contributing! exciting, I pulled your test branch down, and making a few commits on it. I do all my dev on the dev branch, and only push to master when I'm ready to update the repo on .org

    I just merged the branches and ran into some issues, currently cleaning them up and hope to have my dev branch updated soon.

  14. Zane Matthew
    Member
    Plugin Author

    Posted 9 months ago #

    Also cool to see it working on your site!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags