Id of the image returned by R back to JS

LabKey Support Forum (Inactive)
Id of the image returned by R back to JS Leo Dashevskiy  2012-09-19 11:19
Status: Closed
 
Hello!

When using LABKEY.WebPart and returning back from R an image, the image, so it seems, gets an id=resultImage.

What if I have 2 copies of the same module with that LABKEY.WebPart, then the id becomes non-unique and things get messy...

Is there some built in way to specify this id (I would append the copy's unique webPartId to it) or do you recommend I manipulate it manually?

Thanks.
-Leo
 
 
Nick Kerr responded:  2012-09-19 13:52
Hi Leo,

Depending on what you are trying to do you could give the report webpart a unique ID on the page and then grab the image from within that scope.

In Ext 4 it would be something like Ext4.DomQuery.select('#<webpart-id> img'). This does depend on what you are trying to do, but if you just need the element then this should work.

Thanks,
Nick
 
Leo Dashevskiy responded:  2012-09-19 14:07
Nick, I am trying to stick it into the Ext.Resizable(), which takes in the 'id' of the element. It is working for me for a single copy, but not for when there are 2. (Looking at the docs, it also can take an element in place of the 'id', may be, I could use that somehow... Btw, I'm still not using Ext4 and so no DomQuery, but jQuery seems to work just fine for these)
 
Leo Dashevskiy responded:  2013-01-09 15:34
Got it to work, though, through, what I would consider ugly, ugly hack.

Had to modify the default 'resultImage' id of the generated images by appending the web part's unique id to it, thus making them all unique.

Is it not bad practice, though, to have non-unique id's in an HTML document? So should the server instead perform this kind of appending?

Thanks.
 
kevink responded:  2013-01-09 16:23
Thanks for the report. I've filed a bug to track the issue here:

https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=16923
 
Dax responded:  2013-01-09 16:44
As an aside, you could also use the new LABKEY.Report.execute API available in 13.1. This does surface the name of the output parameter as the name property of the ScriptOutput returned for each output parameter. You still would need to "uniquify" the name but you could do that either in your R script or via a parameter you pass in.
 
Leo Dashevskiy responded:  2013-01-10 00:11
Thanks Kevin.

Dax, I will explore the new API shortly, though, it is a new, experimental feature, right? And the old way of doing things have been thoroughly used elsewhere and so should still be kept in working order, so I think...
 
Dax responded:  2013-01-10 07:50
No, the new execute API is not an experimental feature. However, it is only available in 13.1.
 
Leo Dashevskiy responded:  2013-01-10 12:44
Oh, ok, I got you, Dax. Will get to version 13.1 in a little bit.