Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter some whitespaces (more then minLength) #20

Open
kotmatpockuh opened this issue Oct 21, 2015 · 1 comment
Open

Enter some whitespaces (more then minLength) #20

kotmatpockuh opened this issue Oct 21, 2015 · 1 comment

Comments

@kotmatpockuh
Copy link

Enter some whitespaces (more then minLength) - as result all posts are fetched. This is bad behaviour, we must trim our input, and call ajax query only if minLength is reached with character, not with whitespace.

@kotmatpockuh
Copy link
Author

in .php you need something like:

                               if (strlen($term) > 0){
                    relevanssi_do_query( $query );
                    $tempPosts = $query->posts;
                }
            } else {
                $tempPosts = array();
                if (strlen($term) > 0){
                    $tempPosts = get_posts( array(
                        'suppress_filters' => false,
                        's'                => $term,
                        'numberposts'      => $this->options['autocomplete_numrows'],
                        'post_type'        => $this->options['autocomplete_posttypes'],
                    ) );
                }

and in .js:

action: 'autocompleteCallback',
                        term: this.term.trim()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant