Hi Bei,

I believe the syntax is incorrect. Either way, that shouldn't crash chrome
:x

Please follow the docs here:
http://code.google.com/chrome/extensions/bookmarks.html#method-update


<http://code.google.com/chrome/extensions/bookmarks.html#method-update>First
of all, your parameters are incorrect. It should be something like this:

>   chrome.bookmarks.update(id, data, function(result) {

      // the callback when it updated, returning back the bookmark node
> itself.

  });


id: is the bookmark node id.
data: currently you can only support "title", so it should be something like
this:  {"title": "hello world"}

When you placed id = 1, that doesn't necessarily mean its the first
bookmark. As the docs state:
"Bookmarks are organized in a tree, where each node in the tree is either a
bookmark or a group (a folder that can contain nodes). Each node in the tree
is represented by a
BookmarkTreeNode<http://code.google.com/chrome/extensions/bookmarks.html#type-BookmarkTreeNode>
 object."

I will give you the initial post to help you get running :) First, lets find
a bookmark that its title is "Gmail" and lets rename it to "hello gmail". To
do this, we need to use the "get" api (
http://code.google.com/chrome/extensions/bookmarks.html#method-get) to
retrieve the id for the bookmark found. We use that id to update it (
http://code.google.com/chrome/extensions/bookmarks.html#method-update).

  chrome.bookmarks.search("Gmail", function(results) {

    for (var r = 0; r < results.length; r++) {

       var result = results[r];

       console.log("Bookmark ID: " + result.id)

       chrome.bookmarks.update(result.id, {"title": "hello gmail"},
> function(result) {

         console.log("updated!")

       });

    }

  });


I hope the above helps! Remember the docs is your best friend!

-Mohamed Mansour


On Sun, Dec 13, 2009 at 4:05 AM, shinjikun <zhang...@itechs.iscas.ac.cn>wrote:

> I tried the chrome.bookmarks.update api in different ways about
> 30~40time, every time it crashes. It's supposed to be like:
>
> chrome.bookmarks.update(id,{title:'xxx'},function(){});
>
> but this won't work, and any of these won't work either:
>
> chrome.bookmarks.update(id,{title:'xxx'});
> chrome.bookmarks.update('1',{});
> chrome.bookmarks.update('1');
>
> Is there anything wrong with the extension system or it's my bad?
>
> Thanks,
> Bei
>
> --
>
> 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<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>
>

--

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