-
I have a simple widget as follow: /**
title: $:/plugins/linonetwo/zx-script/zx-script-output.js
type: application/javascript
module-type: widget
*/
(function () {
const Widget = require('$:/core/modules/widgets/widget.js').widget;
class ZXOutputWidget extends Widget {
/**
* Lifecycle method: call this.initialise and super
*/
constructor(parseTreeNode, options) {
super(parseTreeNode, options);
this.initialise(parseTreeNode, options);
}
get stateTiddlerTitle() {
const title = this.getAttribute('title', 'aaa.mjs');
const stateTiddlerTitle = `$:/state/linonetwo/zx-script/output/${title}`;
return stateTiddlerTitle;
}
/**
* Lifecycle method: Render this widget into the DOM
*/
render(parent, nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
// DEBUG: console
console.log(`rerender`);
const outputElement = this.document.createElement('article');
outputElement.innerHTML = $tw.wiki.getTiddlerText(this.stateTiddlerTitle);
parent.insertBefore(outputElement, nextSibling);
this.domNodes.push(outputElement);
}
refresh(changedTiddlers) {
return this.stateTiddlerTitle in changedTiddlers && changedTiddlers[this.stateTiddlerTitle]?.modified;
}
}
exports['zx-script-output'] = ZXOutputWidget;
})(); I can see I wonder why, since transclude widget is just doing like this background: I'm displaying zx's output in this widget using creator: LinOnetwo
tags: $:/tags/ViewTemplate
title: $:/plugins/linonetwo/zx-script/OutputBar
type: text/vnd.tiddlywiki
<$zx-script-output title={{!!title}} /> |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Unable to solve this... Use wikitext suggest by a friend: <$vars currentTiddler={{{[{!!title}addprefix[$:/state/linonetwo/zx-script/output/]] }}}>
{{||$:/core/ui/ViewTemplate/body}}
</$vars> The output is pretty good, can even render the output as rendered tiddler. |
Beta Was this translation helpful? Give feedback.
-
You need to call |
Beta Was this translation helpful? Give feedback.
You need to call
refreshSelf()
insiderefresh()
when the conditions are met for needing a refresh. Just returning true does not trigger a refresh of the widget.