No results found. Try again with different words?

Search must be at least 3 characters.

Auto-Close Mockup Comment After New Comment

In some cases, you’ll want to automatically close the comment bubble when you submit a new comment to speed up your workflow. You can modify this using the built-in javascript hooks on the comment view.

First you’ll want to create a new blank javascript file. Let’s call it my-close-after-comment.js. Inside the file, we’ll add this code:

(function($){
    $(document).ready(function() {

        /**
         * Hook into ImageView initialize method
         */
        wp.hooks.addAction('Huddle.CommentView.initialize', function (view) {
            view.messageAfterFirstComment();
        });

        /**
         * Extend the original comment view
         * Here we can add our own functions, events, whatever we like.
         */
        _.extend(Huddle.CommentView.prototype, {
            // add message function
            messageAfterFirstComment: function () {
                this.listenTo(this.model.items, 'successOnSave', function () {
                    // (optional) wait a specific amount of time
                    _.delay(_.bind(function(){
                        this.model.trigger( 'hideClick', this );
                    }, this), 500);
                });
            }
        });
    });
}(jQuery));

Here we’re hooking into the comment thread view’s initialize function and listening for the successful comment submission event. When an comment is successfully added, we’ll wait a half a second (500 milliseconds) and close the box.

Then, add your script to the  ProjectHuddle Project page to add this to your projects.

Was this article helpful?


Did not find a solution? We are here to help you succeed.

Auto-Close Mockup Comment After New Comment

In some cases, you’ll want to automatically close the comment bubble when you submit a new comment to speed up your workflow. You can modify this using the built-in javascript hooks on the comment view.

First you’ll want to create a new blank javascript file. Let’s call it my-close-after-comment.js. Inside the file, we’ll add this code:

(function($){
    $(document).ready(function() {

        /**
         * Hook into ImageView initialize method
         */
        wp.hooks.addAction('Huddle.CommentView.initialize', function (view) {
            view.messageAfterFirstComment();
        });

        /**
         * Extend the original comment view
         * Here we can add our own functions, events, whatever we like.
         */
        _.extend(Huddle.CommentView.prototype, {
            // add message function
            messageAfterFirstComment: function () {
                this.listenTo(this.model.items, 'successOnSave', function () {
                    // (optional) wait a specific amount of time
                    _.delay(_.bind(function(){
                        this.model.trigger( 'hideClick', this );
                    }, this), 500);
                });
            }
        });
    });
}(jQuery));

Here we’re hooking into the comment thread view’s initialize function and listening for the successful comment submission event. When an comment is successfully added, we’ll wait a half a second (500 milliseconds) and close the box.

Then, add your script to the  ProjectHuddle Project page to add this to your projects.

Leave a Reply

Your email address will not be published. Required fields are marked *

LET’S GET STARTED

Ready to Give It a Try?

Start Your Free 14-Day Trial Now. No Obligation. No Reason Not To.

Trial Icon

14 Days Free Trial

Experience Our Platform Risk-Free

Docs Icon

Documentation

Articles that cover common questions

24/7 World Class Support Team

Friendly Support

Reach Out – We’re Here to Help

Scroll to Top