Labs/Jetpack/JEP/22: Difference between revisions

Line 56: Line 56:
// perhaps we add this functionality to the 'current tab' object or all tabs
// perhaps we add this functionality to the 'current tab' object or all tabs


// bookmarks is an iterator-like object with length properties
// results is an iterator-like object with length properties


dump(bookmarks.count); // 3
function callback(results) {


bookmarks[2].remove();
  dump(results.count); // 3


bookmarks[1].title = "Groucho, we hardly knew ye!";
  for (let item in results) {
    insertIntoDOM(results[item]);  
    // insertIntoDOM is a defined by you to display the
    // result item (bookmark or history object)
  }


bookmarks[1].tag("myhero"); // auto saves tags
  results[2].remove();


bookmarks[1].tags(); // returns ["myhero", "mustachioed-funny-guys",]
  results[1].title = "Groucho, we hardly knew ye!";


bookmarks[1].save(); // called to make all changes permanent
  results[1].tag("myhero"); // auto saves tags


function callback(results) {// do something with this}
  results[1].tags(); // returns ["myhero", "mustachioed-funny-guys",]
 
  results[1].save(); // called to make all changes permanent
 
}


jetpack.places.fetch({ where:bookmarks,  
jetpack.places.fetch({ where:bookmarks,  
                         tags: ["marx-brothers"] }, callback);
                         tags: ["marx-brothers"] }, callback);
564

edits