-
-
I don’t like the way the default search works in the Tower theme. Clicking the magnifying glass expands the new “Search…” row, but it doesn’t put focus there. So, searching requires a click on the magnifying glass and then a second click in the newly opened row before the user can begin typing a search term.
How can I fix this?
Thank you.
-
Hello,
Please go to file js/main.js and find this function:
function codelessSearchButton(){ "use strict"; $('.open_search_button').click(function(){ if($('body').hasClass('open_search')){ $('body').removeClass('open_search'); }else $('body').addClass('open_search'); });
edit it to this:
function codelessSearchButton(){ "use strict"; $('.open_search_button').click(function(){ if($('body').hasClass('open_search')){ $('body').removeClass('open_search'); }else { $('body').addClass('open_search'); $('.search_bar input[type="text"]').focus();} });
I have added only this line:
$('.search_bar input[type="text"]').focus();
Save file and refresh.Best regards!
- This reply was modified 8 years, 6 months ago by Mirela. Reason: code edit
-
Thank you!
Fyi, it’s a little bit misleading to indent the new line with the focus() call on it, unless you put braces around both these lines after the “else”. Without the braces, the new line of code will fire regardless of whether the “if” expression is true or false. Indenting it the way you show here makes it seem like the new line of code is part of the “else” block, when it’s not.
Thank you again, though; problem solved.
-
Hello,
Thank you for your suggestion. I already edited the code.
Best regards!
-
Do you have any advice about how I can implement this in my child theme? Using the functions.php content shown at https://wordpress.stackexchange.com/questions/163301/versioning-import-of-parent-themes-style-css, my site doesn’t pick up /js/main.js.
-
Hello,
You can unregister the script and register the new one in your child theme.
Or you can add the function a t custom js box at theme options and overwrite the search function.Best regards!
-
-
Hello,
@CaryMillsap,
This is the only edit you need to do. It is tested and it works. Please open up a new ticket and send us your ftp credentials in a private reply.
Add this topic for reference.Adding your credentials in this topic will make them accessible to the topic author too.
Best regards!
-
-
Hello,
I opened this link: https://37.60.240.179/~methodr8/# and the search field does have focus as soon as you click on the search icon. See screen recording of it: https://drive.google.com/file/d/0B51Lyn41UgszOW42TWZMZnlCUjA/view
Did you manage to fix your issue?
Let us know.Best regards!
-
Thank you. I had been unable to get it to work in Chrome. I tried in Safari, and it worked. Noting that your video was Chrome, I tried a hard refresh (Shift-Cmd-R), and voilà, yes, it works in Chrome, too. Thank you for your patience and help.
Is there any chance you could include this in a future version of Tower? It would help more people than just me…
-
Hello,
Yes, sure. I have already notified the developers. Thank you for suggesting.
If you have other suggestions, please do not hesitate to send them to us. Just open a ticket in this other forum, dedicated for them:
https://support.codeless.co/?forum=suggest-us-featuresBest regards!
- This reply was modified 7 years, 6 months ago by Mirela.
-
You must be logged in to reply to this topic.