On Sunday, July 6, 2014 11:24:01 AM UTC-7, Antaeus Feldspar wrote:
>
> "offset", and three buttons, each of which has an onClick() handler
> defined. Each of them calls a function that I defined in a systemConfig
> plugin, called "tiddlerOfThis", which simply returns the result of:
>
>
> store.getTiddler(story.findContainingTiddler(this).getAttribute("tiddler")));
>
> I thought that this would basically return "whatever tiddler the button
> that got clicked is on", and that it would be simple to write a procedure
> "reschedule (t)" that extracts the date from "alertDate", adds a number of
> days determined by "offset", then writes the new value back to "alertDate".
>
> What actually happens, instead, as far as I can see a pattern, is:
>
> - when the accessing of the data variables of the tiddler takes place
> inside a function defined in a plugin, and the handler of the button on the
> tiddler does not reference those variables, the button works, but ONLY on
> the formTemplate itself. If the button is pressed on a tiddler that is
> derived from that formTemplate, it does not do anything at all in response
> to the click.
>
> - when the data variables are referenced ONLY in the onClick handler
> itself, the button works, but ONLY on tiddlers derived from the
> formTemplate. If the button is pressed on the formTemplate itself, it does
> not do anything at all in response to the click
>
It sounds like your function is reference the *wrong* "this". The variable
"this" is automatically instantiated by the javascript function call
handler, and refers to the object context of the function that is being
processed at the time. For a global function, the object context is the
"window" object, not the calling button. For your function to operate on
the correct DOM element (the button), you need to pass the "this" object
from the onclick event handler, like this:
-----------------
<input type="button" onclick="... tiddlerOfThis(this) ..." ... >
-----------------
where your plugin-defined function looks like:
-----------------
function tiddlerOfThis(here) {
return
store.getTiddler(story.findContainingTiddler(here).getAttribute("tiddler")));
}
-----------------
Note the use of variable name "here" instead of "this", so that the
function works on the context passed to it, instead of the current function
context (i.e., "this").
let me know how it goes...
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://TiddlyTools.github.com/fundraising.html#MakeADonation
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact
--
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.
For more options, visit https://groups.google.com/d/optout.