Dear all,
I would like to execute events when a tiddler is renamed, but even though I
wrote my startup module from the snippets of
"$:/plugins/tiddlywiki/savetrail/savetrail.js", for some reason only the
default text "Relinking 'X' to 'Y'" appears in the developer console,
"RENAMED" and "RELINKED" no (so it doesn't seem to execute the hook). On
page load it prints "LOADED" to the console, so it loads the startup
module. I also thought that I might just not be able to write to the
console, so I also tried to create a tiddler, but that didn't happen
either. What could be the problem?
/*\
title: $:/plugins/bimlas/my-plugin/startup/relink-or-rename.js
type: application/javascript
module-type: startup
Hook on rename
\*/
(function() {
/*jslint node: true, browser: false */
/*global $tw: true */
"use strict";
// Export name and synchronous status
exports.name = "my-rename-hook";
exports.platforms = ["browser"];
exports.after = ["startup"];
exports.synchronous = true;
exports.startup = function() {
console.log('LOADED');
$tw.hooks.addHook("th-renaming-tiddler",function handleEvent(newTiddler,
tiddler) {
console.log('RENAME',newTiddler);
$tw.wiki.addTiddler(new $tw.Tiddler({title: "NAME CHANGED", text:
"rename"}));
return newTiddler;
});
$tw.hooks.addHook("th-relinking-tiddler",function handleEvent(newTiddler,
tiddler) {
console.log('RELINK', newTiddler);
$tw.wiki.addTiddler(new $tw.Tiddler({title: "NAME CHANGED", text:
"relink"}));
return newTiddler;
});
};
})();
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/08c12df3-02f4-4077-b1c0-73cd7561556e%40googlegroups.com.