I'm trying to create a button which creates a new tiddler with a field
value one larger than the previous max value in that field. I'm using the
mathjs plugin and also plan to use the domtext macro to feed the value into
the sendmessage widget call.
My code is using the element hierarchy p->$list->$calc. The 'p' is there
so I can eventually use the domtext macro.
But I'm not there yet because when I click my button, I get this error:
Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The
node before which the new node is to be inserted is not a child of this
node.
Here is my code:
<!-- display the matching tiddlers -->
<$list filter="[has[binindex]!nsort[binindex]limit[10]]"/>
<!-- Find the lowest unused binindex value greater than or equal to zero -->
<p id="nextindex" style="display:inline;">
<$list filter="[has[binindex]!nsort[binindex]limit[1]]" emptyMessage="0">
<$calc>{{!!binindex}}+1</$calc>
</$list>
</p>
<!-- Create new tiddler. Eventually will use the domtext macro to set the
binindex from above calculation. For now just a hard-coded value -->
<$button>
<$action-sendmessage $message="tm-new-tiddler" binindex="15"
text="test"/>
New
</$button>
Paste this code into a new tiddler at
http://mklauber.github.io/tiddly-mathjs/latest.html and click the "New"
button and the above error should result.
I looked into it a little and couldn't tell if the listwidget is at fault
for passing a wrong nextSibling to the calc widget or if the calc widget
somehow did something wrong to cause the listwidget to calculate a wrong
nextSibling. Anyone have any ideas?
As a workaround, I tried to replace the listwidget with a set widget. This
prevented the error, but now I'm having a refresh issue. Every time I click
the 'new' button, the same value is reused for binindex until I force the
entire tiddler containing this code to be refreshed by closing and
reopening.
<!-- display the matching tiddlers -->
<$list filter="0 [get[binindex]] +[!nsort[]limit[10]]"/>
<!-- Find the lowest unused binindex value greater than zero -->
<p id="nextindex" style="display:inline;">
<$set filter="0 [get[binindex]] +[!nsort[]limit[1]]" name="maxindex">
<$calc><<maxindex>>+1</$calc>
</$set>
</p>
<!-- Create new tiddler -->
<$button>
<$action-sendmessage $message="tm-new-tiddler" binindex=<<domtext
nextindex>> text="test"/>
New
</$button>
Paste the above code into a new tiddler at
http://tobibeer.github.io/tw5-plugins and click the new button multiple
times. The $list widget at the top of the tiddler changes each time I hit
the 'new' button, but $calc value doesn't change until I close and re-open
the tiddler. And since the $calc value didn't change, each new tiddler gets
the same binindex value.
Brian
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/CAO5X8CxR1Fuy57_fOpsonxt%2BioNnPzha94ChV8qo8yTENObTpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.