Here is a problem which I suspect is a jquery problem within tw, but
since I'm such a noob, I don't really know.

I'm trying to adapt the ListNav plugin (http://www.hawksworx.com/
journal/wp-content/uploads/2009/03/listnavplugin.html#ListNavPlugin
%20ExampleListNav) so that I can use jQuery to grab columns (the first
column for the moment) from a tw table.

This version of ListNav grabs raw lines from the tiddler body.

In my jqTables macro, I'm stuck for the moment, with this error
message:

   1. Error while executing macro <<jqTables>>:
   2. TypeError: $("<li />").text(itm).appendTo is not a function

I'm perplexed because I'm following very directly ListNav and the
error message can't be right.

ListNav:

   // read list items from tiddler contents
    var text = store.getTiddlerText(title);
    if(text) {

     // generate nav bar
     $("<div />").attr("id", "listnav-nav").appendTo(place);

     // generate list
     var items = text.split("\n");
     var list = $("<ul />").attr("id", "listnav").appendTo(place);
     $.each(items, function(i, itm) {
       $("<li />").text(itm).appendTo(list);
     });

The pertinent bit from my jqTables (Full code at end of this
message):

     // read list items from tiddler contents
     var text = store.getTiddlerText(title);

     text=wikifyStatic(text);

     if($(text).find("table")) {

         // generate div
         $("<div /><ul />").attr("id",
"ListTableColumn").appendTo(place);

         // generate list
         var items = $(text).find("tr td:nth-child(1)");
         $.each(items, function(i, itm) {
            $("<li />").text(itm).appendTo(place);
          });

Everything works fine according to Firebug, though I lose track
precisely at .each.

Here are some of my questions:

For ListNav:
        Why would listNav use .text(itm) when the itm is already simple text?
I suppose it is the only way to give the itm to jquery.
        How can you append to place and assign a variable to the
appending? ... to the appended list?
For my jqTables:
        How can the error be precisely at the line of ListNav that I did not
change, except to append to place?
        If I change one line, there is no error. All I have to do is
add .text():

                 var items = $(text).find("tr td:nth-child(1)").text();

        It doesn't do what I want, but there is no error. (It glues all the
found items into a string and then puts each letter as an item in the
output list.)


Full jqTables code:

(function($) { //# set up alias

// create macro object
config.macros.jqTables = {

        // Add a handler function to be invoked by <<jqTables TiddlerTitle>>
        handler: function(place, macroName, params, wikifier, paramString,
tiddler) {

                // target tiddler passed in as macro parameter
                var title = params[0];

                // read list items from tiddler contents
                var text = store.getTiddlerText(title);

                text=wikifyStatic(text);

                if($(text).find("table")) {

                    $("<div /><ul />").attr("id",
"ListTableColumn").appendTo(place);
                     // generate list
                    var items = $(text).find("tr td:nth-child(1)");
                    $.each(items, function(i, itm) {
                       $("<li />").text(itm).appendTo(place);
                     });

                }
        }

};


})(jQuery);

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
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/tiddlywikidev?hl=en.

Reply via email to