Author Topic: Javascript events  (Read 3042 times)

Offline Omir

  • Jr. Member
  • **
  • Posts: 26
Javascript events
« on: June 06, 2014, 08:14:22 AM »
Is there a list of available javascript hooks anywhere?

I'm looking for one when a contact is added to a group, I can see here a brief list:
http://trac.roundcube.net/wiki/Plugin_Events#beforeandafter

It makes it sound like you can prefix any event with before, but when I change listupdate to beforelistupdate it stops working?

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Re: Javascript events
« Reply #1 on: June 06, 2014, 11:27:27 AM »
before- and after- is only for commands. See this.command method in app.js.

Offline Omir

  • Jr. Member
  • **
  • Posts: 26
Re: Javascript events
« Reply #2 on: June 06, 2014, 01:08:51 PM »
Hmm ok I'm not sure what I'm trying to do is going to be possible then. On the address book screen I want to alter the label to show in brackets how many contacts the group contains.

For this to update after a contact has been drag and dropped into a group. I've tried using the group_addmembers hook but it only allows me to either abort or change the message that is shown client side, I think I need to be able to send some javascript back that will update the label

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Re: Javascript events
« Reply #3 on: June 06, 2014, 01:34:30 PM »
One way is $RCMAIL->output->command('your_command', $arguments), then on client side you need to define rcube_webmail.prototype.your_command function.

Offline Omir

  • Jr. Member
  • **
  • Posts: 26
Re: Javascript events
« Reply #4 on: June 09, 2014, 07:01:53 AM »
Hi Alex thanks for reply

When you say to define the client side function rcube_webmail.prototype.your_command, is this different to using the register_command function like follows?

rcmail.register_command('mycommand', mycommand_function, true);

function mycommand_function() {
    alert('test');
}

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Re: Javascript events
« Reply #5 on: June 09, 2014, 08:25:04 AM »
There's a small difference. To execute mycommand_function() you need $RCMAIL->output->command('command', 'mycommand', $arguments),