User Tools

Site Tools


script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
script [2014/03/24 21:29]
l [prerender and postrender]
script [2017/10/09 20:39] (current)
Line 1: Line 1:
 +<- [[stylesheet|Changing Your Story'​s Appearance]] --------- [[custom_macro|Writing Your Own Macros]]->​
 +
 ===== Scripts ===== ===== Scripts =====
  
Line 9: Line 11:
  
 **Remember:​** script passages must //only// contain Javascript. **Remember:​** script passages must //only// contain Javascript.
 +
 +
 +====Coding in Twine==
 +
 +  * More details about coding in Twine can be found under [[code|Why Use Code]]?
 +  * Other common questions are handled in the [[frequently_asked_questions|FAQ]].
 +
 +
 ====Requesting jQuery==== ====Requesting jQuery====
  
Line 15: Line 25:
 You can also request the [[http://​modernizr.com|Modernizr]] library with the words "​requires Modernizr"​. You can also request the [[http://​modernizr.com|Modernizr]] library with the words "​requires Modernizr"​.
  
-A reminder: you do **not** need to call $.noConflict() when you first invoke jQuery in Twine 1.4 or higher.+A reminder: you do **not** need to call ''​$.noConflict()'' ​when you first invoke jQuery in Twine 1.4 or higher.
 ====prerender and postrender==== ====prerender and postrender====
  
Line 28: Line 38:
     ...     ...
 };</​code>​ };</​code>​
-When ''​postrender.hello''​ is called, ''​this''​ is the Passage object which is currently being rendered, and the first argument ''​a''​ is the <div class="​body content">​ element into which the passage'​s code has been rendered. You can thus transform or modify the div's contents in interesting ways.+When ''​postrender.hello''​ is called, ''​this''​ is the Passage object which is currently being rendered, and the first argument ''​a''​ is the ''​<div class="​body content">​'' ​element into which the passage'​s code has been rendered. You can thus transform or modify the div's contents in interesting ways.
  
 ''​postrender''​ functions are called just after the passage'​s code is rendered into the div. ''​prerender''​ functions are called just before then. ''​postrender''​ functions are called just after the passage'​s code is rendered into the div. ''​prerender''​ functions are called just before then.
Line 42: Line 52:
  
 If you use a lot of scripts from many people, note that as of 1.4.1, naming collisions in the ''​macros'',​ ''​postrender''​ and ''​prerender''​ objects (such as, adding macros which have the same name) are not alerted to the author. Take care that each addition to these objects has a unique name. If you use a lot of scripts from many people, note that as of 1.4.1, naming collisions in the ''​macros'',​ ''​postrender''​ and ''​prerender''​ objects (such as, adding macros which have the same name) are not alerted to the author. Take care that each addition to these objects has a unique name.
 +
 +<- [[stylesheet|Changing Your Story'​s Appearance]] --------- [[custom_macro|Writing Your Own Macros]]->​
script.1395710983.txt.gz ยท Last modified: 2017/10/09 20:37 (external edit)