Question

Okay i have created an observer for bookmark service,
a function is triggered by the observer,when a bookmark item is removedonItemRemoved: function(id, folder, index)

Arguments in the function are (id,folder,index)
When i try to access the bookmark URL and title usinggetItemTitle(id) and getBookmarkURI(id).spec; i get an NSI ILLEGAL VALUE ERROR.
the id of the bookmark is an integer (1935 etc)
Can't see why the bookmark URL is not returned? any clue?

Was it helpful?

Solution

When the bookmark item is removed the id will no longer be useful. The onItemRemoved method takes more arguments than the three that you mentioned though, it takes aId, aParentId, aIndex, aItemType, aURI, ... so you can use the aURI argument to get the url that you are interested in.

The better option is to use the sdk/places/events module though, like so:

const { events } = require('sdk/places/events');

events.on('bookmark-item-removed', ({ data }) => {
  let url = data.url;
  // ...
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top