• Hi

    I am using the jQuery Select Plugin intergrated into WordPress to generate an auto suggestion text box.

    I need when a result is clicked in the drop down for it to automatically follow a link rather than place the result back into the textbox, so it autosubmits when you click a result for instance, but I can’t figure out what I’m missing/how to override it.

    This is the code;

    Registering it…
    jQuery("#applicant-search-input").suggest(ajaxurl + "?action=search", { delay: 500, minchars: 2});

    Integrating it…

    wp_enqueue_script( 'jobman-admin', JOBMAN_URL . '/js/admin.js', false, JOBMAN_VERSION );
            wp_enqueue_script('suggest');

    Using It…

    function search_query(){
        global $wpdb;
        $query = "SELECT * FROM wp_postmeta where meta_value like('".$_GET['q']."%') and meta_key in('data2') GROUP BY post_id";
        $myrows = $wpdb->get_results( $query );
        return $myrows;
    }
    
    function applicant_search() {
        $myrows = search_query();
        foreach($myrows as $key=>$row){
            echo $row->meta_value."\n";
            echo '<span class="meta_value" style="display: none;">'; echo $row->meta_value.'</span>';
    
        }
        die();
    }

    Displaying it…

    <p class="search-box">
    	<label class="screen-reader-text" for="post-search-input">Search Applicants:</label>
            <form method="get" action="/wp-admin/admin.php">
                <input type="hidden" name="page" value="list-applications" />
                <input type="hidden" name="search" value="1" />
                <input type="search" id="search-input" name="q" value="" />
                <input type="submit" name="" id="search-submit" class="button" value="Search Applicants">
            </form>
        </p>

  • The topic ‘jQuery Suggest Overriding’ is closed to new replies.