Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Removing toggle property of search box

    Hello,

    I'm a complete noobie to JavaScript so my apologies in advance if I'm asking something totally stupid.

    I'm trying to get a website up and running using WordPress. A particular plug-in for WP makes the site I'm building mobile-phone etc friendly - and I have a question regarding some JS that is part of the plug-in.

    Before people think badly of me, the licensing terms of the plug-in allow users to modify the code, but the suppliers will not respond for requests for help in doing so. I'm therefore having to see whether I can figure out how to do this myself.

    If I've understood correctly, the extract of code below will show/hide a search box when the user clicks on the search button on the menu page. However, I would like the search box to always be visible when the user visits the menu page (but not on any other pages).

    With the extract provided, could anybody tell me please, how to change the code to keep the search box permanently visible?

    With many thanks in advance
    Darren

    PS I've only selected what I think are the important lines of code - hope I've included enough ....

    Code:
    var touchJS = jQuery.noConflict();
     
    /* Toggling the search bar from within the menu */
    	touchJS( 'a#tab-search' ).unbind( 'click' ).click( function() {
    		
    		touchJS( '#search-bar' ).toggleClass( 'show-search' );
    		touchJS( this ).toggleClass( 'search-toggle-open' );
    		
    		if ( touchJS( '#search-bar' ).hasClass( 'show-search' ) ) {
    			touchJS( 'input#search-input' ).focus();
    		} else{
    			touchJS( 'input#search-input' ).blur();		
    		}
    		return false;
    	});

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,550
    Thanks
    78
    Thanked 4,382 Times in 4,347 Posts
    Well, we have to *guess* what the meaning of some of that is, but I would certainly guess that the culprit are these lines:
    Code:
        touchJS( '#search-bar' ).toggleClass( 'show-search' );
        touchJS( this ).toggleClass( 'search-toggle-open' );
    Seems to clealy be saying it is toggling the class of the objects. So try commenting out those lines and see if the toggle effect doesn't go away.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks, OP!

    I really appreciate your suggestion - which I tried, but I'm afraid it didn't work. All it did was to disable the button, so that when you click on it, the search bar stays hidden.

    Being new to JS, I didn't know whether it was "standard" code that would therefore be quite easy to change.

    I'll do so more investigating to see if there's anything else that might need changing.

    Thank you, however, for your help
    Darren


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •