NB: Strictly development-related issues are better discussed on the dev
group (http://groups.google.com/group/TiddlyWikiDev/) - you're more
likely to get competent help there.
Say I need the name of a tiddler in the event function of
createTiddlyButton
The way you presented it, with the function defined inside the macro
handler, it should just work - you might wanna read up on JavaScript's
scoping rules and closures.
Assuming your code looks a little different than your example, you have
a variety of options - e.g. caching data on the respective DOM element:
config.macros.foo = {
locale: {
btnLabel: Foo,
btnTooltip: lorem ipsum
},
handler: function(place, macroName, params, wikifier,
paramString, tiddler) {
var btn = createTiddlyButton(place, this.locale.btnLabel,
this.locale.btnTooltip, this.onClick,
null, null, null, null);
// use the DOM element to cache data
btn.setAttribute(myTitle, tiddler.title);
// ... optionally using jQuery
jQuery(btn).data(myTiddler, tiddler);
},
onClick: function(ev) {
var e = ev || window.event;
var btn = resolveTarget(e);
// retrieve cached data
var title = btn.getATtribute(myTitle);
var tiddler = jQuery(btn).data(myTiddler);
// ...
}
};
There are plenty of examples of this in the the TiddlyWiki core code, as
well as in various plugins.
HTH.
-- F.
--
You received this message because you are subscribed to the Google Groups
TiddlyWiki group.
To post to this group, send email to tiddlyw...@googlegroups.com.
To unsubscribe from this group, send email to
tiddlywiki+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.