Closed (fixed)
Project:
Facebook-style Statuses (Microblog)
Version:
6.x-3.0
Component:
Submodules
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Mar 2012 at 18:00 UTC
Updated:
26 May 2012 at 05:30 UTC
Currently when adding comments they are added without page refresh, with AHAH. Which is great, but i would like to call a Jquery line to refresh some elements when new comments is added.
$('.views-fluidgrid-wrapper').masonry( 'reload' );
it is for masonry plugin. So when user enters new comment I want to call the above, where to put this code if hacking JS of this module is done, or if not, which JS to override?
Comments
Comment #1
icecreamyou commentedThe easiest way to do it is just by binding to the status-comment-form "submit" trigger, e.g.:
If you want your code to execute after FBSS is done reloading things, you can try to work with the "ahah_success" trigger, and you'll have to bind on the wrapper div that FBSS uses to determine what needs to be replaced.
Comment #2
Marko B commentedThat would be my first though also, but i tried this and it doesnt work
in your latest DEV in fbcomments.js
Drupal.behaviors.fbss_comments = function (context) {
i added
and i get no alert when i add comment, tried it also with
but what do works is if i put just alert("ddd"); in Drupal.behaviors.fbss_comments = function (context) {
as it seems this whole " Drupal.behaviors.fbss_comments " functon is loaded once more when I add comment, dont know if this is normal? Is this how it is supposed to work? and page is not in reloaded, just comment part so AHAH is working.
Comment #3
Marko B commentedI added all of this 3 below to fbss_comments.js and none of them gets called when I submit a comment. This was on a your latest dev version of FBSS, just installed. Any ideas?
Comment #4
icecreamyou commentedHmm, I don't know why the submit trigger wouldn't call but I can reproduce that. For the ahah_success trigger you have to bind on the right div, not the form, and there's no easy way to do that for comments. I am not sure what to tell you off the top of my head, I would have to dig through the layers to figure this out myself.
Comment #5
Marko B commentedFrom what i realised the whole behaviour function is loaded again when submiting, put alert in root of function and you will see. So guessing that then submit can't be called as it is recreated only after this reload.
Comment #6
Marko B commentedI'll try to figure this out, although i am not sure i have knowledge to do it, maybe i find some nasty hack.-
Anyway this is what I was building http://www.pribadaca.com/ its a pinterest clone, all built with drupal and fbss/fbsmp.
Comment #7
icecreamyou commentedNice! Honestly I'm not sure where to start. Probably the easiest thing would be to add a class to the div wrapper that FBSSC uses to determine what needs to be replaced by AJAX when a comment is submitted, and then bind to the "ahah_success" event on that. If that works, I'll accept a patch to FBSS to add that class in.
Comment #8
icecreamyou commentedI just committed a fix to dev that makes it possible to use something like this code to react when a comment is saved:
Note that generally you will replace
jQuery(document).find('.fbss-comments-replace')with$('.fbss-comments-replace', context). The former you can run in Firebug or a JS console; the latter you would put in a module wrapped inside the usual Drupal JS boilerplate.(Also committed to D7.)
Comment #9
Marko B commentedI still don't have any action, i tried this in fbss_comments.js
ctxt.find('.fbss-comments-replace').bind('ahah_success', function() {
alert("ddd");
});
and i dont get any alert, i added your fix to my code and class="fbss-comments-replace" is there but nothing is happening when submiting, you are getting response with this?
Comment #10
icecreamyou commentedDon't edit module files; it will make upgrading a humongous pain later.
If you type the code in #8 into a JS console and the class is in the right place and you don't have any JS errors on the page, the code inside the callback function will run when a comment on a status update is saved.