This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/dev/

Do nothing widget tutorial

2nd February 2019 at 2:55pm

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:

/*\

Do nothing widget

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var Widget = require("$:/core/modules/widgets/widget.js").widget;

exports.donothing = Widget;

})();
That code does 2 key things:

Here's what it looks like:

[ { "title": "$:/DefaultTiddlers", "text": "[[do nothing widget]]" } ] [ { "title": "donothing.js", "text": "/*\\\n\nDo nothing widget\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nvar Widget = require(\"$:/core/modules/widgets/widget.js\").widget;\n\nexports.donothing = Widget;\n\n})();\n", "created": "20190201115945945", "modified": "20190201222441271", "module-type": "widget", "tags": "", "type": "application/javascript" } ] [ { "title": "do nothing widget", "text": "\n```\n<$donothing/>\n```\n\nRenders as:\n\n<$donothing/>\n" } ]
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