2 messages in com.googlegroups.google-gadgets-apiHow to tell when prefs.set() completes?
FromSent OnAttachments
larryb25 Jun 2007 10:10 
Dann (Google Employee)25 Jun 2007 16:22 
Subject:How to tell when prefs.set() completes?
From:larryb (lar@learningapi.com)
Date:06/25/2007 10:10:22 AM
List:com.googlegroups.google-gadgets-api

I've got a URL gadget that has its prefs.set() called from a popup window (user logs in to an intranet site in the popup, javascript sets an ecrypted version of their internal ID in the gadget so the gadget can display personalized information). Once the prefs are set, I have the iframe reload so that it immediately reflects the users logged-in status. The problem is that if I call prefs.set and then immediately trigger a refresh of the gadget, the prefs.set never completes.

The code looks like this:

function setLoginKey(key){ if (key!=null && !(key == '')){ // call google method to set the prefs variable var prefs = new _IG_Prefs(); prefs.set("key", key); // rewrite the url to reflect the new pref - can't just reload since the prefs in the query string are no longer correct var url = document.location.href; url = url.replace(/up_key/,"no_key"); // reload the gadget document.location = url+"&up_key="+key; }

If I comment out the 'document.location = ... ' line, the prefs get set, otherwise the http call to google never actually happens. Is there a way to detect when the prefs.set() call to Google has been made so I can then refresh the gadget?

Thanks, Larry