1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-04 23:39:57 +00:00
TiddlyWiki5/editions/dev/tiddlers/javascript-widget-tutorial/Do nothing widget tutorial.tid
btheado 6af3eb539b
Adds a javascript widget tutorial to the dev tiddlywiki edition (#7016)
* Initial widget tutorials extracted from https://btheado.github.io/tw-widget-tutorial/

* Fixes for refresh behavior change
2022-10-30 16:10:12 +00:00

26 lines
844 B
Plaintext

created: 20190201232102417
modified: 20190202145547621
tags:
title: Do nothing widget tutorial
type: text/vnd.tiddlywiki
In order to define a widget in a tiddler, the tiddler must satisfy these requirements:
* type field is application/javascript
* module-type field is widget
* the text field contains the javascript code
The [[donothing.js]] tiddler fulfills the requirements and its code looks like this:
{{donothing.js}}
That code does 2 key things:
* Imports the core Widget class ([[$:/core/modules/widgets/widget.js]])
* exports the class in an attribute with the name we want our widget to have (`donothing`)
Here's what it looks like:
{{Do nothing widget demo}}
And it worked. No error message this time.
''Exercise'': Modify [[donothing.js]] and [[Do nothing widget demo]] so the widget is named `noop` instead of `donothing`