Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

call additional function when posting a comment

just want to call an additional js function when posting a new comment to a discussion, and then another once the comment has posted.

any and all help gratefully appreciated - really, just looking for the correct file to edit in order to achieve this :D

Comments

  • basically, when you hit 'submit', i was a js function to fire, the comment get posted and rendered, then another js function to fire.

  • ah, thanks for the help, kasper!

    i'm still having trouble getting the function to work, but i'll keep on keeping on!

  • peregrineperegrine MVP
    edited October 2013

    @sock

    i'm still having trouble getting the function to work, but i'll keep on keeping on!

    post your changes - perhaps you have a syntax error.

    don't know your version of vanilla though!

    http://vanillaforums.org/discussion/23130/forum-post-ettikett-etiquette

    http://vanillaforums.org/discussion/17954/food-for-thought-forum-etiquette

    functionality of jQuery .on() is entirely jQuery version dependent

    in 2.0.18.8

      $(frm).triggerHandler('BeforeSubmit', [frm, btn]);
          alert("hello");  // popup hello
          $.ajax({
    
    
      // Let listeners know that the comment was added.
                   $(document).trigger('CommentAdded');
                    alert("comment added");  // popup comment added
                   $(frm).triggerHandler('complete');
                }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • 2.0.18.4, and jquery... 1.8 i think

    all i'm trying to do is to call rainbow.show() when the post gets fired off to the server, and rainbow.hide() once the post renders.

  • hold yer horses, it's working :D

  • socksock
    edited October 2013
    $(frm).triggerHandler('BeforeSubmit', [frm, btn]);
        rainbow.show();  // love the rainbow
        $.ajax({
    
    // Let listeners know that the comment was added.
        $(document).trigger('CommentAdded');
        rainbow.hide();  // kill the rainbow
        $(frm).triggerHandler('complete');
    }
    

    i guess it was a cache issue, as it required one more hard refresh to get it working. thanks both - you've been a great help :)

  • peregrineperegrine MVP
    edited October 2013

    sock said:
    2.0.18.4, and jquery... 1.8 i think

    probably not, unless you modified things.

    2.0.18.4 comes with jQuery 1.6.2

    2.1.x comes with jQuery 1.7.2

    It's good to know your version and its capabilities when creating jQuery functions and scripts.

    you can easily find out by running this script in your console. or looking in source code, this script is easier in my opinion.

    var version = $().jquery;
    alert("My Version of jQuery is " + version);
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • no, it's definitely 1.8, ta :)

    also, had to call rainbow.hide() after the draft autosave finished.

  • peregrineperegrine MVP
    edited October 2013

    so you changed the jQuery version from the default that comes with vanilla:) it might break things in dashboard sorting categories, etc. just be aware.

    edit: it would be interesting to find out if you can drag and drop categories in dashboard with ver 1.8 (didn't realize there was a 1.8, thought it was 1.8.x :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • yes - it's been running with zero problems for quite some time now (that i've noticed ;))

  • peregrineperegrine MVP
    edited October 2013

    you should upgrade to vanilla 2.0.18.8 for the sake of security, if you didn't already apply individual file changes.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.