Is there a way to call the action-listops widget from a javascript macro? Otherwise, I need the functionality of removing an item from a list field.
Thanks.
Is there a way to call the action-listops widget from a javascript macro? Otherwise, I need the functionality of removing an item from a list field.
Thanks.
What are you trying to accomplish? What does your macro do?
JavaScript macros should not modify the tiddler store in any manner, and any macros that do run the risk of breaking with future core updates.
Upon the detection of the deletion of a tiddler, it could potentially update specifically defined/configured list fields that contain references to the tiddler being deleted, removing that item from the list field (aiding data integrity). At this point, this macro is very experimental.
Here is an example of executing wikitext actions every time a tiddler is deleted:
Example actions:
Thank you, very helpful. Using the example, how would the hook.js pass the field name to the action; and how would the action reference the passed variable. In the example, it appears the action calls the action-listops with a hardcoded value of $field=“stream-list”.
Craig
That last argument defines variables that are available to the actions.
I tired:
$tw.rootWidget.invokeActionsByTag("$:/tags/deleteTiddlerAction",null,{currentTiddler : tiddlerToDelete.fields.title}, {fieldName : myfieldName});
Is that correct? OR:
$tw.rootWidget.invokeActionsByTag("$:/tags/deleteTiddlerAction",null,{currentTiddler : tiddlerToDelete.fields.title, fieldName : myfieldName});
How do I reference the variable, fieldName in this case, in the action? This does not look right. $field=<<fieldName>>
The second option. Whatever you call the variable in JavaScript is what you would use in wikitext. So with the code you provided the variable is named fieldName.
Thank you, All working as expect. Craig.