I want to set a variable from inside my callback to a sendRequest
function.

The mappy extension gives an example of doing this but I can't seem to
manage it using global or local variables.

Here's mappy's code for reference:
<script>
// Global accessor that the popup uses.
var addresses = {};
var selectedAddress = null;
var selectedId = null;

function updateAddress(tabId) {
  chrome.tabs.sendRequest(tabId, {}, function(address) {
    addresses[tabId] = address;
    if (!address) {
      chrome.pageAction.hide(tabId);
    } else {
      chrome.pageAction.show(tabId);
      if (selectedId == tabId) {
        updateSelected(tabId);
      }
    }
  });
}
...

In the response function, address is changed which is convenient.
What is it about addresses that let's it retain value even in the
mystical space of messages?

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to 
chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to