Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 03-27-2009, 06:19 AM Open Social
SolidEagle's Avatar
Experienced Talker

Posts: 30
Name: Arjan Nijmeijer
Location: Stadskanaal
Trades: 0
Hi,

First of all I want to apologise for this short title.. I forgot to edit this after I wrote my problem.. and now I can't find an edit button....

I'm making an Open Social gadget and i'm having a little problem a.t.m. I've got a object which is built the OO way. When initializing an object you have to give a parameter containing the variable name (this is used for making correct id's so it would be possible to use more of the same objects and have different ID's). So this object builds his own skin with divs with ID's like: this.InstanceName+"_content" etc. an example:

If I initialize a var gadget like:

var gadget = new object("gadget");

it would generate a div like:

<div id="gadget_content">

same for:

var midget = new object("midget");

would give you <div id="midget_content"> ... you'll get the point.

The object contains some variables and some functions one of these functions is getInstanceName() which will return the name of the instance (the parameter which you gave to the object). I can call this method with this.getInstanceName() cause the "this" variable is a.t.m. my instance.

So far no problems. But im building an OpenSocial gadget and I have to use the gadgets.io.makeRequest function to get data from another app.

This function works like:
gadgets.io.makeRequest(jsonGenerateFileUrl, this.callbackFunction, this.params);

jsonGenerateFileUrl = is a PHP file which will generate a JSON object and ruturns it.

this.callbackFunction = a function declared in my object which will get the JSON object and will show it on the screen.

this.params =
this.params = {}; this.params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
and is nothing more than a parameter that tells the gadgets.io.makeRequest() will return a JSON object.

When I call this function it will return a correct JSON file and it wil go to a callback function in my object, which will show the json data in the content div of the app.

The problem is when I made the request the "this" variabele is not my instance anymore but a window object :S so I can't use my own method: this.getInstanceName(). The problem with this is, that I can't get the correct div cause I should use: document.getElementById(this.getInstanceName()+"_c ontent"); but the "this" variable is not my instance anymore so it returns undefined.

I would like to avoid hardcoded ocument.getElementById("gadget_content"); this btw does work but only if you call your variable gadget..

Does anyone of you know the solution of this problem?

link to the app: http://www.nijm.nl/cvhj/cvhjgadget.xml

you can see it working at:

http://solidarjan.hyves.com/gapsb <-- need to register I'm afraid :S else add the gadget in Orkut (login = your google account)
__________________
The Eagle Soars Above You!

Please login or register to view this content. Registration is FREE

Last edited by SolidEagle; 03-27-2009 at 06:33 AM.. Reason: wanted to apologise for not having a proper title ><
SolidEagle is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Open Social
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08705 seconds with 12 queries