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 [2019/01/22 04:23] – [The Zotero Object] dstillman | dev:client_coding:javascript_api [2019/01/22 04:26] – [API Methods] dstillman |
---|
| |
//The Zotero JavaScript API is under-documented, and at present requires a lot of looking around in the source code. The most useful parts of the source code are in chrome/content/zotero/xpcom and xpcom/data, and the chrome/content/zotero (particularly zoteroPane.js and fileInterface.js).// | //The Zotero JavaScript API is under-documented, and at present requires a lot of looking around in the source code. The most useful parts of the source code are in chrome/content/zotero/xpcom and xpcom/data, and the chrome/content/zotero (particularly zoteroPane.js and fileInterface.js).// |
| |
Once you have access to the core Zotero object, you can use the objects and methods provided by the Zotero JavaScript API. | |
| |
Zotero uses a combination of instantiatable objects (e.g. ''Zotero.Item = function(){...}'') and singletons (''Zotero.Items = **new** function(){...}''). The most important example of the former is ''Zotero.Item'', which represents a single item in the database. Singletons are used mostly to group related static methods into a single namespace. | |
| |
==== Adding items and modifying data ==== | ==== Adding items and modifying data ==== |
| |
A typical operation might include a call to ''Items.get()'' to retrieve an ''Item'' instance, calls to ''Item'' methods on the retrieved object to modify data, and finally a ''save()'' to save the modified data to the database. | A typical operation might include a call to ''Zotero.Items.get()'' to retrieve a ''Zotero.Item'' instance, calls to ''Zotero.Item'' methods on the retrieved object to modify data, and finally a ''save()'' (within a transaction) or ''saveTx()'' (outside a transaction) to save the modified data to the database. |
| |
<code javascript> | <code javascript> |