SitePoint Sponsor

User Tag List

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

    Question jquery slider issues

    First, I think I need to show you what I'm trying to accomplish:

    1) Go to: http://eataustineat.com/testfolder/index.php
    2) Type in a 'd' into the search box
    3) Select the first result, Dog Almighty
    4) Click the "Something!" tab in the row of tabs above the results listings.

    You should notice information corresponding to the item you selected. The list of results and the displaying of the associated information is queryed using SQL and ajax controls the displaying of the information in the div "results2" (under the "Something!" tab).

    I need for the coda-slider over to the something tab automatically when i link is selected, but this is not happening because of an asyncronus javascript issue (that's the best way I can summerize it.)

    How do I fix this problem, or am I going about this entirly wrong?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    This might work, didn't test test it. Depends on how the slider functions.

    Code JAVASCRIPT:
    $('body').click(function(evt) {
    	if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) {
    		$('a[href=#2]').trigger('click');
    	}
    });

  3. #3
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oddz View Post
    This might work, didn't test test it. Depends on how the slider functions.

    Code JAVASCRIPT:
    $('body').click(function(evt) {
    	if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) {
    		$('a[href=#2]').trigger('click');
    	}
    });
    so if i understand this code correctly, it says that when a link is clicked, if it is of type 'cross-link', then it appends goes to index.php#2. what is being passed in as 'evt'? just placing in this code doesn't work.

    here is the jquery code for a.cross-link in the coda-slider:
    Code JavaScript:
    // Same-page cross-linking
    jQuery("a.cross-link").click(function(){
        jQuery(this).parents().find(".stripNav ul li a:eq(" + (parseInt(jQuery(this).attr("href").slice(1)) - 1) + ")").trigger('click');
    			});

  4. #4
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did i just use this wrong? i'm not sure. i understand what the code you provided is trying to do, but I just can't get it to work.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Could try the first part alone to see if the click is even getting picked up.

    Code JAVASCRIPT:
    $('body').click(function(evt) {
        if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) {
            alert('clicked');
        }
    });

  6. #6
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope. no elert message unfortunantly.

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Are these happening after the DOM has fully loaded?

  8. #8
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by oddz View Post
    Are these happening after the DOM has fully loaded?
    the list of results is populated through the use of SQL commands managed by a PHP file (searchtest.php), and dynamically displayed using ajax so I guess the answer to you're question is no.

    the text input is constructed like this:
    Code HTML4Strict:
    <input onkeyup="getName(this.value)" type="text" />

    here is the code for generating the list of results:
    Code JavaScript:
    	function getName(value) {
    		$.post("searchtest.php",{partialName:value},function(data) { $("#results").html(data);
     
    		})
    		}

    in turn, searchtest.php spits out results:
    PHP Code:
    echo "<a class=\"cross-link\" href=\"javascript:ajaxpage('result.php?id=$ID', 'results2');\">".$name."</a><div id=\"contentarea\"></div>"

  9. #9
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,151
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Code JAVASCRIPT:
    $(document).ready(function() {
        $('body').click(function(evt) {
            if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) {
                alert('clicked');
            }
        });
    });

    Anything?

  10. #10
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so the code you posted previously displayed the alert message, so I went ahead and changed swapped

    this line:
    Code JavaScript:
    alert('clicked');

    for this line:
    Code JavaScript:
    $('a[href=#2]').trigger('click');

    and it will move the slider over, but I get this error is firebug:

    Code:
    too much recursion
    [Break on this error] (function(){var Q=/((?:\((?:\([^()]+\)...,typeof J==="string"?J:J+"px")}})})();
    the above error points me to the jquery.js file (which i have attached as jquery.txt). how do I stop this apparent infinite recursiveness!
    Attached Files Attached Files


Tags for this Thread

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
  •