[TW5] Modals and footer: macros don't work in footer (maybe)

96 views
Skip to first unread message

mauloop

unread,
Aug 30, 2018, 4:25:33 PM8/30/18
to TiddlyWiki
Someone can help me to understand this behaviour?

Let's have the following tiddlers:

title: My Tiddler

<$button>
My Modal
<$action-sendmessage $message="tm-modal" $param="My Modal" />
</$button>


title: My Modal
footer: <<btn>><$button message="tm-close-tiddler">{{$:/core/images/close-button}}</$button>

\define btn() <$button message="tm-close-tiddler">{{$:/core/images/done-button}}</$button>

<<btn>>

I should have two buttons in the footer of My Modal, a "Done" button and a "Cancel" button, but the first one, that is defined using a macro, does not appear. Just the "Cancel" button is visible.

I put the same macro in My Modal body as well, just to test that it works. I knew that footer content is wikified and I see that it really is, since the Button widget used for the "Cancel" button works. It looks like there are some issues parsing a macro included in the footer field. Or maybe the only issue it's me.

BTW: 
Using a Macrocall widget does not solve. 
I tested the described scenario on tiddlywiki.com

Any suggestion? Thanks,

)+(au

mauloop

unread,
Aug 30, 2018, 5:15:57 PM8/30/18
to TiddlyWiki
Don't ask me why, it works this way:

title: My Tiddler

\define btn() <$button message="tm-close-tiddler">{{$:/core/images/done-button}}</$button>

<$button>
My Modal
<$action-sendmessage $message="tm-modal" $param="My Modal"  btn=<<btn>> />
</$button>

title: My Modal
footer: <<btn>><$button message="tm-close-tiddler">{{$:/core/images/close-button}}</$button>

!It works

Still searching for someone who helps me to understand.

)+(au

Jeremy Ruston

unread,
Aug 31, 2018, 4:58:19 AM8/31/18
to tiddl...@googlegroups.com
Hi Mauloop

The problem here is that the “btn” variable is defined within the body of the “My Modal” tiddler which means that it only accessible within that tiddler, and so isn’t accessible when the footer is rendered.

Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/39dbc364-8c92-40f7-8d33-a7e0d3360d4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mauloop

unread,
Aug 31, 2018, 5:34:16 AM8/31/18
to TiddlyWiki
Thanks for the explanation, Jeremy. I don't understand the rendering mechanism very well, and this is the cause of most of my mistakes. I have to study hard :(((

The previous examples was just to show the behaviour I was investigating, but it was almost useless. Here is a real (somewhat simplified) use case.

  • The "Done" button should appear only if all of the fields in the form are filled.
  • In my scenario the number and the names of fields to check could change (unpredictable)

Just drag'n'drop the attached json on tiddlywiki.com and open "My Tiddler" to test. Using the workaround as from my last post I should pass all of the needed macros as params to the tm-modal message. A little bit garbled but it works. It would be nice if there was an easiest way to achieve the same result.

Best regards,

)+(au
MyModalExample.json

Jeremy Ruston

unread,
Aug 31, 2018, 6:58:09 AM8/31/18
to tiddl...@googlegroups.com
Hi Mauloop
That’s a very compelling scenario, and it’s a shame that it’s harder than it should be.

At the moment the title, body and footer of modals are separate, independent things. One possibility is a new mode where the body contains the entire modal, including the title and footer. The user would just need to use the right CSS class names to get the standard styling, or they could run with their own.

Best wishes

Jeremy.



Best regards,

)+(au

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.
<MyModalExample.json>

Reply all
Reply to author
Forward
0 new messages