That's a lot of great trouble shooting information, thank you.
I'm sure it'll come in handy a lot in the future. 

Your example code works great in a tiddler <html> tag and makes a lot of 
sense to me, but it doesn't actually work in the plug-in for some reason..
Though thankfully another Tw user was able to get things working:
http://pastebin.com/tifxw1JB

Though when I look at the code he used to get things working... I don't 
really understand why it works at all... ^^; 


On Wednesday, February 6, 2013 1:32:11 PM UTC-8, Yakov wrote:
>
> Hi,
>
> I think I have the solution. First, let me tell you one important 
> principle for debugging: if you have a complex system, to debug, try to get 
> the simplest piece of it which seems to have the bug and debug that one. In 
> this case, I event haven't tried the plugin; instead, I put an inline html 
> like this to try to make it work:
>
> <html><a href="javascript:;" 
> onclick="config.macros.newTiddler.onClickNewTiddler();" title="Create a new 
> tiddler" class="button" accesskey="N" newtitle="New Tiddler" 
> isjournal="false" params="sampleTag" newfocus="title" newtemplate="2" 
> newtext="sampleText">sampleLabel</a></html>
>
> If you try this, you'll see that this doesn't work, so this small piece 
> has some problem. Next, I took a look at the code of the 
> config.macros.newTiddler.onClickNewTiddler [1]. I know that getAttribute 
> method is somewhat from DOM, not TiddlyWiki core and is applied to (called 
> by) a DOM element, so it "should work". Though, the call is 
> "this.getAttribute("newTitle")", so "this" should be the element itself. 
> But when I write just "config.macros.newTiddler.onClickNewTiddler();", 
> "this" is "config.macros.newTiddler" which has nothing to do with my "a" 
> element. So I checked what is "this" in the main context in the following 
> way:
>
> <html><a href="javascript:;" onclick="
> console.log(this);
> " title="Create a new tiddler" class="button" accesskey="N" newtitle="New 
> Tiddler" isjournal="false" params="sampleTag" newfocus="title" 
> newtemplate="2" newtext="sampleText">sampleLabel</a></html>
>
> Here console.log is the method to write to the console (in Opera is opened 
> by ctrl+shift+I and selecting the console tab, in FireBug there's such tab 
> also) and the console sais:
>
> <a href="javascript:;" onclick=" console.log(this); " title="Create a new 
> tiddler" class="button" accesskey="N" newtitle="New Tiddler" 
> isjournal="false" params="sampleTag" newfocus="title" newtemplate="2" 
> newtext="sampleText">sampleLabel</a>
>
> So "this" is the element itself, just what I need. Hence, I add this 
> context to the "config.macros.newTiddler.onClickNewTiddler" in this way:
>
> <html><a href="javascript:;" onclick="
> config.macros.newTiddler.onClickNewTiddler.apply(this);
> " title="Create a new tiddler" class="button" accesskey="N" newtitle="New 
> Tiddler" isjournal="false" params="sampleTag" newfocus="title" 
> newtemplate="2" newtext="sampleText">sampleLabel</a></html>
>
> and that worked! If you'd like to learn some more details, I'd recommend 
> to read more about "this" and scopes in JavaScript, may be [2] will be 
> helpfull.
>
>
> Now the solutions seems to be the following:
>
> var ah ="<a href=\"javascript:;\" 
> onclick=\"config.macros.newTiddler.onClickNewTiddler.apply(this);\" 
> title=\"Create a new tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" 
> isjournal=\"false\" newfocus=\"title\" newtemplate=\"2\">+</a>";
>
> (though, I haven't tested this inside the plugin)
>
>
> Best regards,
> Yakov.
>
> [1] 
> https://github.com/TiddlyWiki/tiddlywiki/blob/master/js/NewTiddler.js#L35
> [2] 
> http://stackoverflow.com/questions/1007340/javascript-function-aliasing-doesnt-seem-to-work
>
> среда, 6 февраля 2013 г., 23:55:43 UTC+4 пользователь Arc Acorn написал:
>>
>> As an example here are some of the things I've tried.
>> All of which simply create a link that doesn't work. 
>>
>> var ah ="<a href=\"javascript:;\" 
>> onclick=\"config.macros.newTiddler.onClickNewTiddler\" title=\"Create a new 
>> tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" isjournal=\"false\" 
>> newfocus=\"title\" newtemplate=\"2\">+</a>";
>>
>> var ah ="<a href=\"javascript:;\" onclick=\"return 
>> config.macros.newTiddler.onClickNewTiddler\" title=\"Create a new tiddler\" 
>> accesskey=\"N\" newtitle=\"New Tiddler\" isjournal=\"false\" 
>> newfocus=\"title\" newtemplate=\"2\">+</a>";
>>
>> var ah ="<a href=\"javascript:;\" onclick=\"return 
>> config.macros.newTiddler.onClickNewTiddler(e)\" title=\"Create a new 
>> tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" isjournal=\"false\" 
>> newfocus=\"title\" newtemplate=\"2\">+</a>";
>>
>> var ah ="<a href=\"javascript:;\" onclick=\"return 
>> config.macros.newTiddler.onClickNewTiddler()\" title=\"Create a new 
>> tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" isjournal=\"false\" 
>> newfocus=\"title\" newtemplate=\"2\">+</a>";
>>
>> var ah ="<a href=\"javascript:;\" onclick=\"return 
>> config.macros.newTiddler.onClickNewTiddler(event)\" title=\"Create a new 
>> tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" isjournal=\"false\" 
>> newfocus=\"title\" 
>>
>> var ah ="<a href=\"javascript:;\" onclick=\"return config.macros.
>> newTiddler.createNewTiddlerButton(place,title,params,label,prompt,accessKey,newFocus,isJournal)\"
>>  
>> title=\"Create a new tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" 
>> isjournal=\"false\" newfocus=\"title\" newtemplate=\"2\">+</a>";
>>
>> var ah ="<a href=\"javascript:;\" 
>> onclick=\"config.macros.newTiddler.onClickNewTiddler(place,title,params,label,prompt,accessKey,newFocus,isJournal)\"
>>  
>> title=\"Create a new tiddler\" accesskey=\"N\" newtitle=\"New Tiddler\" 
>> isjournal=\"false\" newfocus=\"title\" newtemplate=\"2\">+</a>";
>>
>

-- 
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 http://groups.google.com/group/tiddlywikidev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to