-
Author
Tagged: doAjaxSearch
-
September 7, 2018 at 09:57 #208788hbcondoParticipant
How do I change the number of characters required before an ajax search is initiated? Right now the default is set at 3 but I need to decrease it.
September 7, 2018 at 20:00 #208870LauraModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
September 7, 2018 at 21:24 #208891RaduModeratorHi,
In what input ? screenshot + link pls
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionSeptember 7, 2018 at 21:49 #208908hbcondoParticipantSee attached screenshots; this is reproducible on Kleo’s demo site. When the magnifying glass is clicked on and search criteria is entered, the search will not be initiated until at least 3 characters are entered.
Trying to review the code and the doAjaxSearch method in app.js has a property called minChars with a default value of 3. How do we specify a different value without changing the original code?
Attachments:
You must be logged in to view attached files.September 10, 2018 at 15:48 #209178RaduModeratorHi,
Check this article
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionSeptember 10, 2018 at 21:13 #209231hbcondoParticipantThanks, but how is this technique going to allow us to specify our own minimum character count rather than using the hard-coded value of 3 in the minChars property? Please provide some insight on this requirement for us.
September 11, 2018 at 18:18 #209313RaduModeratorSo you will be able to edit the app.js file for your needs like how you pointed our in this screenshot : https://cdn.seventhqueen.com/sq-support/wp-content/uploads/2018/09/doAjaxSearch.png
Just do that and there you will be able to edit the app js file in child.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionSeptember 12, 2018 at 10:05 #209366hbcondoParticipantCould you please provide a code snippet of how to implement doAjaxSearch in a child theme js file? Thank you.
September 12, 2018 at 17:34 #209443RaduModeratorHi,
I don’t have premade for that and not sure if the function can be rerwiten like a php one, but i had offered to you a possibility to overwrite the app.js file in child to be able to change that function params into app.js file in child.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionSeptember 13, 2018 at 06:37 #209481hbcondoParticipantSo the possibility is for us to maintain an entire copy of app.js, which is over 4000 lines of code, just to change one line of code in it? There’s no way to override just doAjaxSearch even though that function has a lot of logic in it?
September 13, 2018 at 15:23 #209512RaduModeratorYes, no snippet like in php cuz it not works in that way.
So you will need to copy and modify in child and using that snippet.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionJanuary 24, 2019 at 00:10 #217222hbcondoParticipantWhy was this ticket marked as resolved? It was not resolved; editing the Kleo app.js file for one parameter is not a resolution and overriding the entire app.js file is not a resolution either. Please review the doAjaxSearch function again. Thanks.
January 24, 2019 at 16:42 #217252RaduModeratorHi,
Sorry the ticket was closed automatically after a certain days
As a solution for your need please add the next snippet to child theme functions.php (make sure to have it activated)
COPY CODEfunction sq7r_deregister_app_js() { $min = sq_option( 'dev_mode', 0 ) == 1 ? '' : '.min'; //Deregister the core theme app script wp_deregister_script( 'app'); wp_dequeue_script( 'app'); //Register again the script but from child theme for custom changes. //This will pull and use the app.min.js or app.js from wp-content/themes/kleo-child/assets/js/app.js and app.min.js wp_register_script( 'app', get_stylesheet_directory_uri() . '/assets/js/app' . $min . '.js', array( 'jquery' ), $version, true ); wp_enqueue_script( 'app', get_stylesheet_directory_uri() . '/assets/js/app' . $min . '.js', array( 'jquery' ), $version, true ); } add_action('wp_enqueue_scripts', 'sq7r_deregister_app_js', 11);
With this snippet it will pull the app.js and/or app.min.js from child theme from same location : http://rdu.local/kleo/wp-content/themes/kleo-child/assets/js/app.js
So place the file modified into child theme and add the snippet and this will be updated proof.Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
You must be logged in to reply to this topic.