Why multiple click on a WidgetButton does not work ?

41 views
Skip to first unread message

vpl

unread,
Apr 4, 2019, 8:45:19 AM4/4/19
to TiddlyWiki
Hi,

I've created a simple javascript macro (called filterbacklog) that display the current date time stamp
I've created a button that trigger the execution of this macro 

<$button actions=<<filterbacklog>> >
Click me!
</$button>


When I click the first time on the button I get the console.log providing the current timestamp
But When I click again on the button (withtout opening again the tiddler) the macro is not executed again ...
As if tiddlywiki was accepting only the first button click event ..

Do you have an idea why this works like that ? Normal ? Workaround ?

Thanks for your help and support

Regards
Vpl





/*\
title: filterbacklog.js
type: application/javascript
module-type: macro

Macro to return the changecount for the current tiddler

\*/
(function(){

exports.name = "filterbacklog";

exports.params = [];

/*
Run the macro
*/
exports.run = function() {
var self = this,
tiddler,
fields = [],
t,f;
var output = [];
var titleVal = [];
var valReturn = "|qsdqsdqsd|\n";
// Collect all the fields
var date = new Date();
var timestamp = date.getTime();
    console.log("filterbacklog 0.5"+timestamp);
return valReturn;
};

})();

Jed Carty

unread,
Apr 4, 2019, 9:07:51 AM4/4/19
to TiddlyWiki
Macros are updated when they are rendered and not updated until they are re-rendered. If you open the tiddler once and don't close it then your setup won't re-render the button and the date value won't update. To get this to update they way you want to have to put something in to force an update. This should work.

<$set name=unused value={{$:/state/SomeStateTiddler!!time}}>
<$button actions=<
<filterbacklog>>>
Click me <$action-setfield $tiddler='$:/state/SomeStateTiddler' $field='time' $value=<
<now>>/>
</$button>
</$set>

the big problem is that the time will be set from the previous time you clicked the button, so clicking it twice in a row gets you the current time.

vpl

unread,
Apr 4, 2019, 9:18:43 AM4/4/19
to TiddlyWiki
And this works !!!

Thanks very much for your help so accurate and responsive ...

Really appreciated

Regards

vpl

S. S.

unread,
Apr 4, 2019, 9:40:01 AM4/4/19
to TiddlyWiki
<<now>> that you have it working, you may also want to read: [TW5] Now date not refreshing in button
Regards!
Reply all
Reply to author
Forward
0 new messages