UPDATE:
Some more things I tried to get the tiddler to render correctly
(unsuccessfully):
- Running a function to delete the tiddler and recreate it with exactly
the same values had no perceivable change. There was no visible change
whatsoever. I wouldn't know the function had run or not if it weren't for
the console log.
- Running a function to close, delete, recreate, and re-open the tiddler
in quick succession had no effect.
- Running a function to add the tiddler to the list, close and re-open
the tiddler, then close and re-open the second tiddler works as explained
above but isn't a real solution.
It appears no matter how many close, open, delete, create or other actions
I string together into a single function (or by adding additional action
widgets to a button widget), the effects of the change don't actually
render (i.e. they happen, just aren't visible) until all actions are
completed. Can anyone confirm this?
This being the case, is there a way to manually trigger the syncer
dispatchTask (for example) so it renders between different actions?
I'm just shooting in the dark at this point.
On Sunday, January 29, 2017 at 5:27:07 PM UTC-5, Novan Leon wrote:
>
> This is a somewhat perplexing issue and I can't seem to find a solution.
> Maybe someone can help.
>
> Background
>
> I'm trying to add the ability to specify alternate view templates to
> specific tiddlers and allow users to toggle them on and off using a toolbar
> button. I did this by making the following changes:
>
> *Change #1*
>
> Add the code below to line 114 of $:/core/modules/widgets/list.js. This
> lets users specify a "multiTemplate" attribute which, if set to "true",
> will prompt the list widget to check the list field of the
> $:/test/DirectLinks/DirectLinksList tiddler to see if it includes the
> current tiddler and if it does, apply the $:/test/DirectLinks/ViewTemplate
> instead of the default $:/core/ui/ViewTemplate.
>
> //Apply direct links view template
> if (this.getAttribute("multiTemplate") == "true") {
> var directLinksTemplate = "$:/test/DirectLinks/ViewTemplate";
> var tiddlerList = "$:/test/DirectLinks/DirectLinksList";
> var applicableTiddlers = $tw.wiki.getTiddlerList(tiddlerList);
>
> if (applicableTiddlers.indexOf(title) !== -1 && !isDraft) {
> template = directLinksTemplate;
> }
> }
>
> *Change #2*
>
> Add the multiTemplate="true" attribute to the list widget in
> $:/core/ui/PageTemplate/story.
>
> *Change #3*
>
> Create the custom view template in question, as well as two buttons, one
> to place in the ViewToolbar to switch the current tiddler to the custom
> template (i.e. by adding the current tiddler to the direct links list) and
> one to place in the custom template to switch the current tiddler back to
> the default view template (i.e. by removing the current tiddler from the
> direct links list).
>
> Both of the buttons in question contain three action widgets:
>
> - Listops action to add or remove the current tiddler title to/from
> the direct links list ($:/test/DirectLinks/DirectLinksList)
> - Close tiddler action to close the current tiddler
> - Navigate action to re-open the current tiddler, presumably with the
> new template applied
>
>
> The Issue
>
>
> Everything seems to work as expected with one exception. When I click the
> "Show direct links" button to add the current tiddler to the direct links
> list and reload the tiddler, the tiddler is added to the list but the
> custom template doesn't apply until I do one of the following things:
>
>
>
> - Refresh the browser
> - Edit the tiddler and cancel/save to return
> - Click the "Show direct links" button on one of the other tiddlers
>
> The last bullet is the one that especially puzzles me. This behavior tells
> me that there IS a way to refresh/re-render a single tiddler rather than
> the entire page but I'm at a loss as to how.
>
>
> Try It For Yourself
>
>
> To experience this behavior for yourself, do the following:
>
>
>
> 1. Open the attached tiddlywiki file (take security precautions before
> opening the file if necessary)
> 2. Click on the "Show direct links" button (image icon on far right)
> on the "Test Bookmark 8" tiddler. The tiddler should close and re-open
> near
> the top of the page. You will notice the name of the tiddler, "Test
> Bookmark 8" has been added to the list shown in the "Test Tiddler" but it
> still looks just like any other tiddler.
> 3. Click on the "Show direct links" button on the "Test Bookmark 7"
> tiddler (or any other bookmark tiddler, the ones with a url field
> defined). The
> tiddler will close and re-open near the top of the page just like the
> previous one, but the previous one "Test Bookmark 8" will now appear with
> the custom template applied.
> 4. If you click on the "Show direct links" button for other tiddlers,
> the same behavior will continue. The one you clicked will move to the top
> and the previous one will appear with the custom template. The tiddlers
> with the custom template applied will show correctly from that point
> forward, all except the one you clicked last. The same thing happens in
> reverse when removing tiddlers from the list.
>
> Thoughts / Questions
>
> Is there a better way to force the refresh/re-rendering of a specific
> tiddler? Clearly, closing the tiddler and re-opening it doesn't appear to
> do this. The nearest I can find is by editing and canceling/saving it to
> return which always works, or by figuring out the how the behavior above
> works.
>
> During the course of my testing I tried putting all of the button actions
> into a custom action widget and executing them together
> ($:/test/DirectLinks/widgets/action-toggletemplate.js). The results were
> the same with one exception, when I tried to automate the closing/opening
> of the second tiddler, I noticed if the tiddlers were navigatedTo from
> inside the story river, it wouldn't have the same refreshing effect. This
> may be irrelevant but it's just something I noticed.
>
> I've spend the last two days racking my head over this and trying to find
> a solution with no luck. I'm hoping maybe someone here with more experience
> may have encountered this before and be able to offer a solution.
>
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/e983c5a9-cc8f-4612-a293-8942f06376f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.