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

icecreamyou’s picture

Status: Active » Fixed

The easiest way to do it is just by binding to the status-comment-form "submit" trigger, e.g.:

$('.fbss-comments-comment-form', context).submit(function() {
  // Your code here
});

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.

Marko B’s picture

That 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

  $('.fbss-comments-comment-form', context).submit(function() {
  alert("ddd");
});

and i get no alert when i add comment, tried it also with

  ctxt.find('.fbss-comments-comment-form').bind('ahah_success', function() {
  });

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.

Marko B’s picture

I 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?

  ctxt.find('.fbss-comments-comment-form').bind('ahah_success', function() {
	alert("ddd");		  
  });
  $('.fbss-comments-comment-form', context).submit(function() {
	alert("ddd1");
  });
   ctxt.find('.fbss-comments-comment-form').submit(function() {
	alert("ddd2");
  })
icecreamyou’s picture

Status: Fixed » Active

Hmm, 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.

Marko B’s picture

From 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.

Marko B’s picture

I'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.

icecreamyou’s picture

Nice! 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.

icecreamyou’s picture

Status: Active » Fixed

I just committed a fix to dev that makes it possible to use something like this code to react when a comment is saved:

jQuery(document).find('.fbss-comments-replace').bind('ahah_success', function() {
  // do things here
});

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.)

Marko B’s picture

I 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?

icecreamyou’s picture

Don'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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.