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

Widget refresh demo III

16th February 2019 at 7:19pm

[ { "title": "$:/DefaultTiddlers", "text": "[[refresh count widget]]" } ] [ { "title": "test", "text": "Text field of tiddler='test'" } ] [ { "title": "refreshcount.js", "text": "/*\\\n\nwidget to count the number of times this widget refreshes\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\nvar MyWidget = function(parseTreeNode, options) {\n\tthis.refreshCount = 0;\n\tthis.initialise(parseTreeNode, options);\n};\n\n/*\nInherit from the base widget class\n*/\nMyWidget.prototype = new Widget();\n\n/*\nRender this widget into the DOM\n*/\nMyWidget.prototype.render = function(parent, nextSibling) {\n\tthis.parentDomNode = parent;\n\tvar textNode = this.document.createTextNode(this.refreshCount + \" refreshes\");\n\tparent.insertBefore(textNode, nextSibling);\n\tthis.domNodes.push(textNode);\n};\n\nMyWidget.prototype.refresh = function(changedTiddlers) {\n\t// Regenerate and rerender the widget and replace the existing DOM node\n\tthis.refreshCount++;\n\tthis.refreshSelf();\n\treturn true;\n};\n\nexports.refreshcount = MyWidget;\n\n})();\n", "created": "20190201005026324", "modified": "20190202143451303", "module-type": "widget", "tags": "", "type": "application/javascript" } ] [ { "title": "refresh count widget", "text": "\n\n*<$button set=\"test!!test\" setTo=\"hello\">Modify a different tiddler</$button>\n*<$button set=\"!!test\" setTo=\"hello\">Modify this tiddler</$button>\n*<$edit-text focus=yes tiddler=test tag=input/>\n\n<div>\n<div style=\"display:inline-block;width: 49%;vertical-align: text-top;word-wrap: break-word;}\">\n\n```\n<$refreshcount/>\n```\n\nRenders as:\n\n<$refreshcount/>\n</div>\n\n<div style=\"display:inline-block;width: 49%;vertical-align: text-top;word-wrap: break-word;}\">\n\n```\n<$list filter=\"[[test]get[text]]\">\n<<currentTiddler>><br>\n<$refreshcount/>\n</$list>\n```\n\nRenders as:\n\n<$list filter=\"[[test]get[text]]\">\n<<currentTiddler>><br>\n<$refreshcount/>\n</$list>\n" } ] </div> </div>