Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: Omir on June 06, 2014, 08:14:22 AM

Title: Javascript events
Post by: Omir 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?
Title: Re: Javascript events
Post by: alec on June 06, 2014, 11:27:27 AM
before- and after- is only for commands. See this.command method in app.js.
Title: Re: Javascript events
Post by: Omir 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
Title: Re: Javascript events
Post by: alec 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.
Title: Re: Javascript events
Post by: Omir 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');
}
Title: Re: Javascript events
Post by: alec 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),