chrome.bookmarks.get(bookmark, function(results) {
ParentNode = results[0];
console.log(ParentNode.title);
});However, I need to be able to get all the enclosing folders. An ugly way of doing that would be this:
chrome.bookmarks.get(bookmark, function(results) {
ParentNode = results[0];
console.log(ParentNode.title);
chrome.bookmarks.get(ParentNode.parentId, function(results) {
ParentNode = results[0];
console.log(ParentNode.title);
chrome.bookmarks.get(ParentNode.parentId, function(results) {
ParentNode = results[0];
console.log(ParentNode.title);
chrome.bookmarks.get(ParentNode.parentId, function(results) {
ParentNode = results[0];
console.log(ParentNode.title);
});
});
});
});But that wouldn't really work. I've tried a while loop:
var ParentNode;
function getTags(bookmark) {
chrome.bookmarks.get(bookmark, function(results) {
ParentNode = results[0];
while (ParentNode.parentId !== "undefined") {
chrome.bookmarks.get(ParentNode.parentId, function(result) {
ParentNode = result[0];
console.log(ParentNode.title);
});
}
});
}
Callbacks are asynchronous. ParentNode is not modified by your loop and so it runs indefinitely. The callback passed to chrome.bookmarks.get will only get a chance to run once the loop completes and control passes back to the JavaScript event loop which never happens.
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/40aff076-b15d-4b62-8232-300c7c27e27b%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.