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 
0
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.
This can be accomplished by looking through the
discussion.jsfile and searching fortriggerandtriggerHandler. I took the liberty of doing so and these two triggers should allow you to do what you need:$(frm).triggerHandler('BeforeSubmit', [frm, btn]);on line 99 and$(document).trigger('CommentAdded');on line 207.These can then be used like this:
$('#Form_Comment').on('BeforeSubmit', function (e) { // Do stuff before submitting the comment }); $(document).on('CommentAdded', function (e) { // Do stuff after the comment was added });Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
ah, thanks for the help, kasper!
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
$(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
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.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
)
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.