On Monday, 22 March 2010 02:40:14 UTC, Saverio wrote:
>
> I am using Eric Shulman's
> http://www.tiddlytools.com/#ToggleScrollingSidebars.
> The toggle does not immediately take effect. It appears that I need
> to open a tiddler before the new setting (either on or off) is
> enforced. This is not the way the plugin behaves on the tiddlytools
> website.
>
> Please see: http://dl.dropbox.com/u/4462381/example.html
>
> for the minimal tiddlywiki file that shows the problem on Firefox 3.6.
>
I've hit the same problem, with a TiddlyWiki based off 2.6.5 running under
Firefox 16.0.2 (with the TiddlyFox 1.0alpha3 extension). I found a fix
which works for me. It may not work with other browsers/versions, but it's
unlikely to make anything worse.
The failure process I'm seeing is as follows.
* The ToggleScrollingSidebars tiddler gets "rendered" twice.
* Both times it patches the onchange callback, then calls the method to set
the behaviour based on the current config option value.
* The second time, it patches it to call through to the patch method, not
the original onchange.
* Therefore, clicking the checkbox gets you into infinite recursion, and
never sets the scrolling behaviour. If you open Firebug, you'll see a "too
much recursion" error message in the console.
The reason the patching goes wrong on the second pass, despite the check
"if (!chk.coreOnChange) { // only once", is as follows.
* On the first run through, chk.coreOnChange is undefined and chk.onchange
is null. So, {{!chk.coreOnChange}} is {{true}}. Therefore
chk.coreOnChangeis set to null and chk.onchange is set to the function in
ToggleScrollingSidebars.
* On the first run through, chk.coreOnChange is null and chk.onchange is
the function in ToggleScrollingSidebars. So, {{!chk.coreOnChange}} is ...
still {{true}}! Therefore chk.coreOnChangeis set to the function in
ToggleScrollingSidebars (because that was the value of chk.onchange) and
chk.onchange is set to ... the same function in ToggleScrollingSidebars --
probably a different function object, but the same behaviour.
* When that function is called by clicking the checkbox, its first line,
"if (this.coreOnChange) this.coreOnChange.apply(this,arguments);" ends up
calling that function itself, because that's now the value in
{{this.coreOnChange}} ... which calls itself again ... whcih ....
There are a few ways you could fix this. I've done so by changing "if
(!chk.coreOnChange) { // only once" to "if (!chk.patchedOnChange) { // only
once" and adding a line "chk.patchedOnChange=true;" inside the if, like
this:
...
'';}}>><<option chkScrollSidebars>><<tiddler {{
var chk=place.lastChild;
if (!chk.patchedOnChange) { // only once
chk.patchedOnChange=true;
chk.coreOnChange=chk.onchange;
chk.onchange=function() {
if (this.coreOnChange) this.coreOnChange.apply(this,arguments);
this.checked=config.options.chkScrollSidebars;
window.ToggleScrollingSidebars_setscroll();
};
}
window.ToggleScrollingSidebars_setscroll();
'';}}>> $1
!end
...
Hope that helps somebody out there -- it took me a few hours to work out!
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/tiddlywiki/-/JqIOG0D2gPMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.