Eric,
Using your sample as is, with the parseInt fix, makes the buttons won't do
anything when clicked. I've checked the error console and no error listed.
However, this code is behaving strangely:
function getHeader(context,count)
{
if (!window.fetStartIndex || window.fetStartIndex < 0)
window.fetStartIndex = 0;
// ensure not to page behind the last page
if (window.fetStartIndex >= count)
window.fetStartIndex =
Math.min(Math.max(window.fetStartIndex-window.fetItemsPerPage,0),count-1);
createTiddlyButton(context.place,"<",null,
function(e) {
// modified according to
https://groups.google.com/forum/#!topic/tiddlywiki/0Q3zVhGK7Os
var c =
parseInt(store.getValue(tiddler,"local_count")) - window.fetItemsPerPage;
store.setValue(tiddler.title,"local_count",c);
window.fetStartIndex = c;
story.refreshTiddler(context.viewerTiddler.title,null,true);
});
createTiddlyButton(context.place,">",null,
function(e) {
// modified according to
https://groups.google.com/forum/#!topic/tiddlywiki/0Q3zVhGK7Os
var c =
parseInt(store.getValue(tiddler,"local_count")) + window.fetItemsPerPage;
store.setValue(tiddler.title,"local_count",c);
window.fetStartIndex = c;
story.refreshTiddler(context.viewerTiddler.title,null,true);
});
var startNo = window.fetStartIndex+1;
var endNo =
Math.min(count,window.fetStartIndex+window.fetItemsPerPage);
return "("+startNo+" - "+endNo+ " of "+ count + "
items)\n{{clear{\n}}}";
}
The buttons will change page only after clicking on them several times.
Sometimes 4 clicks is necessary to change page, sometimes 2, and so on. Do
you know what's going on?
On Monday, March 9, 2009 7:32:51 AM UTC+7, Eric Shulman wrote:
>
> > <script>
> > var CountValue = store.getValue(tiddler, "VerseCount");
> > </script>
>
> * This actually creates another global variable, window.CountValue,
> which isn't really necessary since store.getValue() can be called
> later on, in response to pressing the "<" or ">" buttons (see
> suggested code changes below).
>
> * Custom field names must be *all lower case* (due a known limitation
> in the core). Thus, you have to use "versecount" or "verse_count" or
> just "vc", instead of "VerseCount".
>
> So, eliminate the global entirely, and then write the 'button' code to
> look something like this:
>
> createTiddlyButton(context.place,"<",null,
> function(e) {
> var c=store.getValue(tiddler,"vc")-window.fetItemsPerPage;
> store.setValue(tiddler.title,"versecount",c);
> window.fetStartIndex = c;
> story.refreshTiddler(context.viewerTiddler.title,null,true);
> });
> createTiddlyButton(context.place,">",null,
> function(e) {
> var c=store.getValue(tiddler,"vc")+window.fetItemsPerPage;
> store.setValue(tiddler.title,"versecount",c);
> window.fetStartIndex = c;
> story.refreshTiddler(context.viewerTiddler.title,null,true);
> });
>
> (note: untested code)
>
> enjoy,
> -e
> Eric Shulman
> TiddlyTools / ELS Design Studios
--
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/groups/opt_out.