Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
a technique for dumping out debugging info for nodes in a JQuery select list. [bll_2009post]
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
buildlackey  
View profile  
 More options Nov 7, 9:18 pm
From: buildlackey <chris.b....@gmail.com>
Date: Sat, 7 Nov 2009 18:18:02 -0800 (PST)
Local: Sat, Nov 7 2009 9:18 pm
Subject: a technique for dumping out debugging info for nodes in a JQuery select list. [bll_2009post]

I've looked around on this list and in a number of books, but nothing
I read helped me figure out how to dump out the content of nodes in a
JQuery select list. I came up with my own technique, which uses good
old fashioned DOM functions to figure out a node’s name and
attributes. There is probably a better way, and I’d welcome
suggestions if you have them.

But for now, I’ll be using the DOM approach employed by the sample
code below.

In a nut-shell, this code uses a JQuery select expression to grab all
nodes that have an id attribute, whose selected attribute is “true”,
and whose name ends in “man”. We iterate through those nodes (actually
only one is found), and dump out its content using DOM functions.

<pre>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <script type="text/javascript"
        src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>

  <script>
  $(document).ready(function(){

 var gatherAttributes = function(attributes) {
        var attribs = ""
        if (attributes) {
            for (var i = 0; i < attributes.length; i++) {
                attribs = attribs + "| "
                    + attributes[i].nodeName + "=" +
                        attributes[i].nodeValue
            }

        }
        return attribs

    }

    var dumpNode = function(node) {
        alert("got a node: " + node.nodeName + " with attributes:  " +
              gatherAttributes(node.attributes)  +
              " /  and inner content = " + $(node).html());
    }

    alert("HI");

    $("input[selected=true][id][name$='man']").each (
             function() {
                 alert("got a match " + $(this).val());
                dumpNode(this);

  });

  });

  </script>

</head>
<body>
  <input id="man-news" name="man-news" >        foo1</input>
  <input name="milkman" >                       foo2</input>
  <input id="fetterman" name="new-fetterman" >  foo3</input>
  <input selected="true" id="letterman" name="new-letterman" >  foo3</
input>
  <input name="newmilk" >                       foo4</input>
</body>
</html>

</pre>

any better way ?   Please let me know.
Thanks !

 Chris

This is a cross post from my blog @ http://buildchimp.com/wordpress/?p=165

_____

Chris Bedford

Founder & Lead Lackey
Build Lackey Labs
http://buildlackey.com


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google