SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help for a newbe!!!

    Hi to all!

    I have the following script for a Live Search", that runs ok.

    Code:
    /* JS File */
    
    // Start Ready
    $(document).ready(function() {  
    
        // Icon Click Focus
        $('div.icon').click(function(){
            $('input#search').focus();
        });
    
        // Live Search
        // On Search Submit and Get Results
        function search() {
            var query_value = $('input#search').val();
            $('b#search-string').html(query_value);
            if(query_value !== ''){
                $.ajax({
                    type: "POST",
                    url: "search.php",
                    data: { query: query_value },
                    cache: false,
                    success: function(html){
                        $("ul#results").html(html);
                    }
                });
            }return false;    
        }
    
        $("input#search").live("keyup", function(e) {
            // Set Timeout
            clearTimeout($.data(this, 'timer'));
    
            // Set Search String
            var search_string = $(this).val();
    
            // Do Search
            if (search_string == '') {
                $("ul#results").fadeOut();
                $('h4#results-text').fadeOut();
            }else{
                $("ul#results").fadeIn();
                $('h4#results-text').fadeIn();
                $(this).data('timer', setTimeout(search, 100));
            };
        });
    
    });
    The problem is that when you click on one of the results to accept it, it open a new tab; I will like to reload the current.

    Any idea?

    Thanks in advance,

    Juan
    Last edited by Force Flow; Jun 8, 2013 at 20:12. Reason: added code tags

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,716
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by juancpa View Post
    The problem is that when you click on one of the results to accept it, it open a new tab; I will like to reload the current.
    None of that code would result in a link being opened in a new tab, so it's likely to be something about the link itself that is resulting in that behavior. Can we see the HTML code for some of the links?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •