Hi all,  im working on a plugin that needs to do some ajax calls. It's  
all working, but im wondering if this is the right way to do it..

I create a button (in a template inside the plugin dir, so that recent  
addition is working great):

<roundcube:button command="plugin.xs4all_greenlist-add" type="input"  
class="button" label="xs4all_greenlist.xs4all_greenlist_add" />

In JS:

rcmail.register_command('plugin.xs4all_greenlist-add',  
'xs4all_greenlist_add' , true);

function xs4all_greenlist_add()
{
  rcmail.http_post('plugin.xs4all_greenlist-add',  
'_greenlist_entry='+entry, true);
}

And in PHP:

$this->register_action('plugin.xs4all_greenlist-add', array($this,  
'xs4all_greenlist_add'));

function xs4all_greenlist_add($args)
  {
    global $OUTPUT;

    ....

    $OUTPUT->command('xs4all_greenlist_add_greenlist_row');
  }

Up to here it was pretty straightforward. But i was fiddling a bit to  
get the ajax return correct. It's returning a JSON reply with an exec  
field that can execute a JS function. I ended up doing this in my js  
file, otherwise the function couldnt be found:

rcube_webmail.prototype.xs4all_greenlist_add_greenlist_row  = function()
{
   .....
}


This seems to be working, but i just want to make sure this is the  
correct way to handle this, before I end up having to change this  
plugin later on.

Thanks,

Cor
_______________________________________________
List info: http://lists.roundcube.net/dev/

Reply via email to