Tips:Using JavaScript in Memento: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 4: Line 4:


== Field tips ==
== Field tips ==
Tips for calling field() for various field types.
Tips for calling ''field()'' for various field types.
{{FieldTypeReturnValues}}
{{FieldTypeReturnValues}}


Line 61: Line 61:
The Link to Entry field has its own structure, unique among the field types.
The Link to Entry field has its own structure, unique among the field types.


==== Using field() to access the value of local and remote field values ====
==== Using ''field()'' to access the value of local and remote field values ====
: '''Argument'''
: '''Argument'''
:# The name of the field whose value you want
:# The name of the field whose value you want
Line 90: Line 90:
|}
|}
<br/>
<br/>
==== Using set() in a trigger to set the value of a local field ====
==== Using ''set()'' in a trigger to set the value of a local field ====
: '''Arguments'''
: '''Arguments'''
:# Name of the field whose value is to be set
:# Name of the field whose value is to be set
Line 134: Line 134:
You'll notice in this page that the code for JavaScript fields and that for triggers are very similar, but also that they different. Here's how they are different:
You'll notice in this page that the code for JavaScript fields and that for triggers are very similar, but also that they different. Here's how they are different:
=== Context ===
=== Context ===
* Context is set for you in a JavaScript field, and that context is the current entry. So, if you call field(), that implicitly invokes the field() function on the current entry.
* Context is set for you in a JavaScript field, and that context is the current entry. So, if you call ''field()'', that implicitly invokes the ''field()'' function on the current entry.
* Context is not set in a trigger, so only global functions are initially available, and using those, you can set up context for functions you want to call on the objects you're interested in.
* Context is not set in a trigger, so only global functions are initially available, and using those, you can set up context for functions you want to call on the objects you're interested in.
{|
{|