Results 1 to 7 of 7

Thread: Help with Cookies Jquery Toolbar

  1. #1
    Join Date
    Sep 2009
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question Help with Cookies Jquery Toolbar

    Hi im currently testing this toolbar script in localhost

    http://www.pvmgarage.com/2009/12/nic...s3-and-jquery/

    Code:
      //hide toolbar and make visible the 'show' button
    	$("span.downarr a").click(function() {
        $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeIn("slow");    
      });
      
      //show toolbar and hide the 'show' button
      $("span.showbar a").click(function() {
        $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeOut();    
      });
    all is working only i need the toolbar to be closed in other page or refresh after user click the hidebutton
    and the bar will only be shown again if user click show button

    i thing i need to use cookie, i found this tutorial below but can't get it working
    http://www.shopdev.co.uk/blog/cookie...sible-layouts/



    can anyone take a look

    TQ

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,982
    Thanks
    16
    Thanked 311 Times in 309 Posts
    Blog Entries
    11

    Default

    JQuery cookies have always worked fine for me but there is nothing in the code you've posted that relates to jQuery cookies. You need to set a cookie on hide, and then delete the cookie on show. Youll also need some if statements that do something once the cookie is found. The part relating to cookies is towards the bottom of the tutorial. Lastly, if you havent already done it, you'll need to have the jQuery cookie plugin linked to your page.

    The cookie logic would go something like;
    Code:
     //hide toolbar and make visible the 'show' button
    	$("span.downarr a").click(function() {
        $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeIn("slow");   
    // set the cookie
      });
      
      //show toolbar and hide the 'show' button
      $("span.showbar a").click(function() {
        $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeOut();   
     // destroy the cookie
      });
    
    if (cookie == found) {
    keep toolbar hidden
    }
    If you need more help, please post a link to your page/sample page - upload it to a temporary testing area and then you can remove it again once you've got it working.
    Last edited by Beverleyh; 03-21-2013 at 06:48 AM.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    mulaus (03-21-2013)

  4. #3
    Join Date
    Sep 2009
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    I have uploaded it here

    i have limited knowledge in jquery but heres what i tried so far

    Code:
      //hide toolbar and make visible the 'show' button
    	$("span.downarr a").click(function() {
        $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeIn("slow");    
           $.cookie('sample1', 'close');
      });
      
      //show toolbar and hide the 'show' button
      $("span.showbar a").click(function() {
        $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeOut();
        $.cookie('sample1', null);
      });
    before </body>

    Code:
    <script type="text/javascript">
    var sample1 = $.cookie('sample1');
      if (sample1 == 'close') {
            $("#toolbar").slideToggle("fast");
        $("#toolbarbut").fadeIn("slow");    
        };
    
    </script>

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,982
    Thanks
    16
    Thanked 311 Times in 309 Posts
    Blog Entries
    11

    Default

    You'll need to download and link to the jQuery cookie plugin too. At the moment you only link to jquery-1.3.2.min.js

    Tested and working;
    Code:
    //hide toolbar and make visible the 'show' button
    $("span.downarr a").click(function() {
    	$("#toolbar").slideToggle("fast");
    	$("#toolbarbut").fadeIn("slow"); 
    	$.cookie('toolbar', 'hide');   
    });
    
      
    //show toolbar and hide the 'show' button
    $("span.showbar a").click(function() {
    	$("#toolbar").slideToggle("fast");
    	$("#toolbarbut").fadeOut(); 
    	$.cookie('toolbar', 'null');   
    });
    
    //cookie action
    var toolbar = $.cookie('toolbar');
    if (toolbar == 'hide') {
        	$("#toolbarbut").fadeIn("slow"); 
    	$("#toolbar").css({"display":"none"});
    };
    Last edited by Beverleyh; 03-21-2013 at 08:50 AM.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  6. The Following User Says Thank You to Beverleyh For This Useful Post:

    mulaus (03-21-2013)

  7. #5
    Join Date
    Sep 2009
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    Thank you Beverly

    You made my day..

    but i have strange issue, i tried in localhost its now working fine but when i tried in live server it is not working . I have reuploaded all the files twice...

    refresh and clear browser cache close reopem browser but its just not working in live server. can you try here if its working 4 u ?

  8. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,982
    Thanks
    16
    Thanked 311 Times in 309 Posts
    Blog Entries
    11

    Default

    Looks like you haven't uploaded the "jquery.cookie.js" file.

    The path in your markup says it should be sat in the same folder as both "jquery-1.3.2.min.js" and your "2.html" web page, but at the moment, it isn't there.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  9. The Following User Says Thank You to Beverleyh For This Useful Post:

    mulaus (03-21-2013)

  10. #7
    Join Date
    Sep 2009
    Posts
    46
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    its there uploaded it twice ...but the file is inaccessible

    i rename it to jquery-cookie.js

    and now its working fine

    Thanks again Beverly :-)

Similar Threads

  1. Replies: 0
    Last Post: 04-28-2011, 01:30 PM
  2. Replies: 16
    Last Post: 11-11-2009, 06:30 AM
  3. Resolved jQuery Cookies plugin
    By Snookerman in forum JavaScript
    Replies: 3
    Last Post: 12-26-2008, 02:01 PM
  4. Cookies instead of session cookies?
    By DisturbedRoach in forum JavaScript
    Replies: 1
    Last Post: 10-21-2008, 09:12 PM
  5. Ie Toolbar
    By Briton in forum HTML
    Replies: 4
    Last Post: 12-06-2005, 07:14 PM

Bookmarks

Posting Permissions

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