Tips:Using JavaScript in Memento: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 11: | Line 11: | ||
== JavaScript tips == | == JavaScript tips == | ||
== Link to Entry fields === | === Link to Entry fields === | ||
; Using field() | ; Using field() | ||
: field() returns an array of Entry objects. To access fields in the linked library, use: | : field() returns an array of Entry objects. To access fields in the linked library, use: | ||
Line 24: | Line 24: | ||
} | } | ||
</source> | </source> | ||
|<source lang="JavaScript"> | |||
var e = entry(), links = e.field("Link field name"); | |||
if (links.length > 0) { | |||
var name = e.field(links[0].field("Name")); | |||
// Put your code to handle name here | |||
} | |||
</source> | |||
|} | |||
{| | |||
! JavaScript field | |||
|- | |||
|<source lang="JavaScript"> | |||
var links = field("Link field name"); | |||
if (links.length > 0) { | |||
var name = field(links[0].field("Name"); | |||
// Put your code to handle name here | |||
} | |||
</source> | |||
|- | |||
! Trigger | |||
|- | |||
|<source lang="JavaScript"> | |<source lang="JavaScript"> | ||
var e = entry(), links = e.field("Link field name"); | var e = entry(), links = e.field("Link field name"); |
Revision as of 03:20, 17 February 2017
« Page as of 2017-02-12, editions Mobile 4.2.1, Desktop 1.0.8 »
This page is under development. Information is incomplete and potentially incorrect.
General tips
JavaScript tips
Link to Entry fields
- Using field()
- field() returns an array of Entry objects. To access fields in the linked library, use:
JavaScript field | Trigger |
---|---|
var links = field("Link field name");
if (links.length > 0) {
var name = field(links[0].field("Name");
// Put your code to handle name here
}
|
var e = entry(), links = e.field("Link field name");
if (links.length > 0) {
var name = e.field(links[0].field("Name"));
// Put your code to handle name here
}
|
JavaScript field |
---|
var links = field("Link field name");
if (links.length > 0) {
var name = field(links[0].field("Name");
// Put your code to handle name here
}
|
Trigger |
var e = entry(), links = e.field("Link field name");
if (links.length > 0) {
var name = e.field(links[0].field("Name"));
// Put your code to handle name here
}
|
JavaScript field tips
Trigger tips
How Trigger & JavaScript field scripts differ
Links
W3Schools | |
---|---|
JavaScript Tutorial | A pleasant, fairly complete, and useful tutorial on JavaScript Best on a computer or tablet in landscape. On a phone or tablet in portrait, scroll to the bottom for navigation. |
Mozilla Developer Network | |
JavaScript Guide | Shows you how to use JavaScript, gives an overview of the language, and presents its capabilities & features |
JavaScript Reference | The entire JavaScript language described in detail |
Introduction to JavaScript | Introduces JavaScript and discusses some of its fundamental concepts |
JavaScript Tutorial | A re-introduction. JavaScript is often derided as being a toy, but beneath its simplicity, powerful language features await. |
JavaScript 1.7 | The JavaScript release upon which Memento is currently based |
About JavaScript | Jumping off point in learning about JavaScript |