[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Jquery - Select Dynamic Elements

Asked by socross in Jquery, JavaScript

Hi

I am having issues selecting a dynamic element, can anyone offer any insight into why?

I have a simply ul which displays dynamic html generated by an onclick element in my page.

I am then trying to access these newly generated elements using normal JQ selectors but it wont work!! I have tried to provide a code sample below.

Many thanks

--s--
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
// THIS JQUERY UPDATES MY UL BASED ON THE ID OF THE BUTTON CLICKED, THE FUNCTION BUILDBUTTONS IS AN AJAX REQUEST TO GET THE NEW HTML
 
		// Generate Buttons (Ajax) Add to Page & Set Active State
		$('ul.pages-icons a').click(function() { //start function when any link is clicked
				
			//var current = $(this).parent("li").find("b").attr("class"); //retrieve id of link so we can use in php file		
			var current = $(this).attr("class"); //retrieve id of link so we can use in php file		
			
			if (current != "active") 
			{
				
		 		var page_id = $(this).attr("id"); //retrieve id of link so we can use in php file		
												   
				//Select this element
				$("ul.pages-icons li a.active").fadeTo("fast", 0).attr('class','off');
				
				// Set current Item Active"page_id="+page_id
				//$("ul.pages-icons-large li#recordsArray_"+page_id).attr('class','active');
				$(this).attr('class','active');
				
					$(".tools-icons").fadeOut(750, function() {
							buildbuttons(page_id);
							
					});
						
			  } // End If
				 
         }); //close click
         
 
// THIS IS THE CODE I USE TO SELECT NEW ELEMENT I NEED TO SELECT i have also tried binding the function to that element
 
 
      $('ul.tools-icons li#offline').click(function () {
			$("#responce").html('Item Clicked');
        ); 
        
        
        
// THIS IS THE HTML LI BEFORE REPLACMENT WHICH I CAN SELECT
 
<div id="tools-outer">
    <div class="table">
        <ul class="tools-icons">
            <li class="offline edit-page"></li>
            <li class="offline page-settings"></li>
            <li class="offline view-sub-pages"></li>
            <li class="offline take-online"></li>
            <li class="offline delete-page"></li>
            <li><a title="" href="javascript:void(0);" class="add-new-page">Add new page</a></li>                    
        </ul>
    </div>
</div>
 
 
// THIS IS THE HTML LI AFTER REPLACMENT WHICH I CANNOT SELECT
 
<div id="tools-outer">
    <div class="table">
        <ul class="tools-icons">
        <li><a title="Edit selected page" href="#" class="edit-page">Edit selected page</a></li>
        <li><a title="Edit selected page settings" href="#" class="page-settings">Edit selected page settings</a></li>
        <li><a title="View sub pages" href="#" class="view-sub-pages">View sub pages</a></li>
        <li id="offline"><a title="Take selected page offline" href="#" class="take-offline" id="8">Take selected page offline</a></li>
        <li id="delete"><a title="Delete selected page" href="#" class="delete-page">Delete selected page</a></li>
        <li><a title="Add new page" href="#" class="add-new-page">Add new page</a></li></ul>
    </div>
</div>
[+][-]06/05/09 11:03 AM, ID: 24558827Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Jquery, JavaScript
Sign Up Now!
Solution Provided By: ShayanOH
Participating Experts: 1
Solution Grade: A
 
[+][-]06/05/09 09:51 AM, ID: 24558180Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/05/09 10:20 AM, ID: 24558418Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625