Solved

jquery plugin on dynamic data

Posted on 2010-08-25
4
489 Views
Last Modified: 2012-05-10
I have a page which outputs an unordered list from the database.  A sample of the output is below.  When the data is placed statically on the page the jquery.treeview works perfectly, but when attempting to post the data dynamically (either in page_load or OnInit) it gives the error "Object doesn't support this property or method".  It doesnt' matter if the code is on the page statically, or if it's placed dynamically:          
$(document).ready(function() {
        $('ul:first').treeview(); });
}
or
 $(document).ready(function() {
        $('$tree').treeview(); });
}

both give the same error.  My question is: How can I make this work, so that the jQuery object is attached to the UL on the page?  I believe that the UL needs to be added to the DOM, but using the onInit it should already be there, shouldn't it?

Thanks,
Geoff
<ul id="tree" class="open treeview-black">

<li value="bbuckley">

<span style="font-weight:bold;">bbuckley</span>

<ul>

<li value="abarnes">

<span style="font-weight:bold;">abarnes</span>

<ul><li>

	<div>

		<table class="gvClass " cellspacing="0" align="Left" rules="all" border="1" style="width:100%;border-collapse:collapse;margin-left:0px;width:100%;">

			<thead>

				<tr>

					<th scope="col">&nbsp;</th><th scope="col">Collector</th><th scope="col">Acct #</th><th scope="col">Name</th><th scope="col">Due Date</th><th scope="col">Amount</th><th scope="col">Method</th><th scope="col">Comments</th>

				</tr>

			</thead><tbody>

				<tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$0')">Delete</a></td><td>abarnes</td><td>102020554</td><td>name 1</td><td style="white-space:nowrap;">Aug 30, 2010</td><td>236</td><td>&nbsp;</td><td>&nbsp;</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$1')">Delete</a></td><td>abarnes</td><td>101731054</td><td>name 2</td><td style="white-space:nowrap;">Aug 21, 2010</td><td>150</td><td>&nbsp;/td><td>&nbsp;</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$2')">Delete</a></td><td>abarnes</td><td>101340084</td><td>name 3</td><td style="white-space:nowrap;">Aug 23, 2010</td><td>50</td><td>&nbsp;</td><td>&nbsp;</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$3')">Delete</a></td><td>abarnes</td><td>101341467</td><td>name 4</td><td style="white-space:nowrap;">Aug 23, 2010</td><td>200</td><td>&nbsp;</td><td>&nbsp;</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$4')">Delete</a></td><td>abarnes</td><td>101033494</td><td>name 5</td><td style="white-space:nowrap;">Sep 02, 2010</td><td>500</td><td>&nbsp;</td><td>2 of 2</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$5')">Delete</a></td><td>abarnes</td><td>102282108</td><td>name 6</td><td style="white-space:nowrap;">Aug 18, 2010</td><td>574</td><td>&nbsp;</td><td>&nbsp;</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$6')">Delete</a></td><td>abarnes</td><td>101260079</td><td>name 7</td><td style="white-space:nowrap;">Aug 24, 2010</td><td>1117.66</td><td>&nbsp;</td><td>&nbsp;</td>

				</tr><tr>

					<td><a href="javascript:__doPostBack('gv_abarnes','Delete$7')">Delete</a></td><td>abarnes</td><td>101100506</td><td>name 8</td><td style="white-space:nowrap;">Aug 23, 2010</td><td>400</td><td>&nbsp;</td><td>&nbsp;</td>

				</tr>

			</tbody><tfoot>



			</tfoot>

		</table>

	</div></li></ul>

	</li></ul>

	</li></ul>

Open in new window

0
Comment
Question by:GeoffSutton
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:wuff
ID: 33523783
To select the <ul> id you should use the '#':

$('#tree')...

Maybe you mistyped in your question.

Are you sure the dynamically generated ul has the id assigned to it?
0
 
LVL 10

Author Comment

by:GeoffSutton
ID: 33523819
I am.  I have tried using the straight ID and the ClientID.  Neither works.  And you're right:  I mistyped the question thanks.
0
 
LVL 3

Expert Comment

by:wuff
ID: 33525120
I found a cool dynatree plugin. Maybe it's helpful?

http://wwwendt.de/tech/dynatree/
0
 
LVL 10

Accepted Solution

by:
GeoffSutton earned 0 total points
ID: 33525854
the problem isn't generating the tree. I have tried 3 different plugins (Collapse, Treeview and JSTree) all the with same effect.  Somehow it's not recognizing the UL as being part of the DOM so the jquery isn't binding to it.
Geoff
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now