SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get xml with clicked class.

    I am currently working on a function with jQuery that searches for the class that was just clicked within xml. But the result only seems to parse me the last entered result. I keep struggeling to get this fixed so I hope someone on sitepoint is able to help me out.

    The jquery looks like this:

    Code:
    $(".links dd").live("click",function(){
    		var linkName = $(this).attr('class');
    		description(linkName);
    	});	
    
    function description(x){
    $(".description").replaceWith('<div class="description">' + description + '</div>');
    		}
    and the XML tree like this:

    HTML Code:
    <linklist>
    	<link title="sitepoint">
    	<class>sitepoint</class>
    	<url>#/sitepoint/</url>
    	<description> This is a excellent site to get help </description>	
            </link>
    
           <link title="google">
    	<class>google</class>
    	<url>#/google/</url>
    	<description> The most used search engine nowadays </description>	
            </link>
    </linklist>
    In this case it would only show me the description of Google, even when I click to see the information/description about sitepoint.

    Thanks in advance,
    Mehk

  2. #2
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am still running into this problem, does anyone have an idea?

  3. #3
    SitePoint Member
    Join Date
    Apr 2010
    Location
    Charlotte, NC
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mehk, can you show the code where you are loading in the XML and also where description is set as a var?
    LinkedIn : VernonK
    Web Development Resources : ChooseDaily.com

  4. #4
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by VernonK View Post
    Mehk, can you show the code where you are loading in the XML and also where description is set as a var?
    Code:
    	$('#list').append('<dl class=\'List\'>');
    	$.getXML('myData.xml', function(data){
    		for(i=0; i<data.programs.length; i++) {
    			var program = data.programs[i].program;
    			//alert(data.programs[i].program.title);
    		var $program = $(this);
    		var title =  (program.title);
    		var class = program.class;
    		var url = (program.url);	
    		var description = (program.description);
    		var imageurl = $program.attr('imageurl');
    		var html = '<dt> <img class="Image" alt="" src="' + imageurl + '" /> </dt>';
    		html += '<dd class=' + class + '>';
    		html += '<a href= ' + url + ' id="nextbuttonLink" class="control">' + title + '</a>';
    		/* html += '<p class="title">' + title + '</p>'; */
    		html += '</dd>';
    	
    		html += '</dl>';
    		$('#List dl').append(html);
    		}

  5. #5
    SitePoint Member
    Join Date
    Nov 2010
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •