[Midas] CALLBACK_CORE_RESOURCES_SELECTED

Zach Mullen zach.mullen at kitware.com
Fri Jul 6 11:01:56 EDT 2012


The callback only receives a list of id's for items that are selected.  You
can map that id to their name from the DOM though:

if(params.items.length > 0) {
    var itemId = params.items[0];
    var itemName = $('#browseTable tr[type="item"][element="'+itemId+'"]
td:first span').html();
    console.log(itemName);
    ...
}


In the javascript code you can print the contents of a variable recursively
to the console by using:

console.log(variable);

This works really well on Chrome, and I'm pretty sure also on Firefox. It's
my preferred method of debugging :)

Thanks,

Zach

On Thu, Jul 5, 2012 at 8:11 PM, Mona Wong <mona at sdsc.edu> wrote:

>
>         I finally got the following to work showing a new entry for
> checkbox'ed item for Midas 3.2.6:
>
> $(document).ready(function()
> {    midas.registerCallback ( 'CALLBACK_CORE_RESOURCES_SELECTED', 'annio',
>        function ( params )
>         {
>             if ( params.items.length > 0 )
>             {
>                 var webroot = json.global.webroot;
>                 var html = '<li><img alt="" src="' + webroot +
>                     '/core/public/images/icons/edit.png"/> <a href="'
>                     + webroot + '/midas/annio/?itemid=' +
>                     params.items.join ( ',' ) + '">Annotate
> image</a></li>';
>
>             params.selectedActionsList.append ( html );
>         }
>     });
> });
>
>         How do I get the item's name (filename) from the params?
>
>         I tried params.items[0].name but that didn't work...
>
> thanks,
> Mona
>
> *********************************************
>     Mona Wong
>     Web & iPad Application Developer
>     San Diego Supercomputer Center
>
>     You are the light you wish to see.
> *********************************************
>
>
>
> _______________________________________________
> Midas mailing list
> Midas at public.kitware.com
> http://public.kitware.com/cgi-bin/mailman/listinfo/midas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/midas/attachments/20120706/41f9e12f/attachment.html>


More information about the Midas mailing list