Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
dev:client_coding:javascript_api [2018/09/08 17:16] – [API Methods] new subsubsection about creating a new collection zuphilip | dev:client_coding:javascript_api [2018/09/09 05:08] – [API Methods] zuphilip | ||
---|---|---|---|
Line 205: | Line 205: | ||
<code javascript> | <code javascript> | ||
async function createCollection(name) { | async function createCollection(name) { | ||
- | | + | |
+ | var collection = new Zotero.Collection(); | ||
collection.name = name; | collection.name = name; | ||
+ | collection.parentID = currentCollection.id; | ||
var collectionID = await collection.saveTx(); | var collectionID = await collection.saveTx(); | ||
return collectionID; | return collectionID; | ||
} | } | ||
</ | </ | ||
+ | |||
+ | This function creates a new collection with a given name and makes | ||
+ | it a subcollection of the currently selected one. Since the saving | ||
+ | will result in a Promise object, we add the '' | ||
+ | function call and make sure that this is within an '' | ||
==== Zotero Search Basics ==== | ==== Zotero Search Basics ==== |