jQuery collapsible sidebar not saving cookies

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 2094 Views - Last Post: 06 August 2013 - 05:56 PM

#1 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 08:52 PM

Hi, I added a jQuery collapsible sidebar to my forum and everything seems to be working except it is not saving cookies. For example, when I close the sidebar it will re-open when the page refreshes. It shouldn't do that. Can someone help me out with this?

This is the tutorial I followed: http://community.myb...read-73062.html

Everything is working perfectly but it is not saving cookies as it is supposed to. Please help me with this. I followed everything correctly.

Is This A Good Question/Topic? 0
  • +

Replies To: jQuery collapsible sidebar not saving cookies

#2 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 08:57 PM

Let us see your code to see what you have done.
Was This Post Helpful? 0
  • +
  • -

#3 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:03 PM

<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
	lang.no_new_posts = "{$lang->no_new_posts}";
	lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>
<style type="text/css">
.buttons {
    background: url(images/godam/arrowright.png) no-repeat;
    width: 28px;
    height: 36px;
    display: block;
    cursor: pointer;
position: relative;
top: 45px;
left: 28px;
}

.clickedbuttons {
    background: url(images/godam/arrowleft.png) no-repeat;
    width: 28px;
    height: 36px;
    display: block;
    cursor: pointer;
position: relative;
top: 45px;
left: 28px;
}
</style>
</head>
<body>
{$header}
<a class="buttons" style="float: right;"></a>
<a class="clickedbuttons" style="float: right;"></a>
<br class="clear" />
<div class="sidebar" style="float: right;width: 19%;">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead"><strong>
Latest News
</strong></td>
</tr>
<tr>
<td class="trow1">
You can put some news stuff here
</td>
</tr>
</table>
</div>
<div class="forums" style="float: left;width: 80%;">
{$ps_header_index}
{$forums}
</div>
<br class="clear" />
{$ps_footer_index}
<table border="0" cellspacing="0" cellpadding="4" class="tborder">
		<tr><td class="thead" colspan="4" align="center"><strong><a href="#">Index Advertising</a></strong></td></tr>
		<tr>
		<td class="trow1" style="text-align: center; font-size:13px;">Make a request to <strong><a href="#">advertise here</a></strong>!</td>		
                
</tr>
	</table>
 <br />
{$boardstats}
<br style="clear: both" />
{$footer}
</body>
</html>


This is the code I added in the index just like the tutorial in the link.
Was This Post Helpful? 0
  • +
  • -

#4 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:20 PM

Where are you adding the js files like these:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/jquery.cookie.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/sidebar.js"></script>


Was This Post Helpful? 0
  • +
  • -

#5 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:30 PM

In the headerinclude template.
Was This Post Helpful? 0
  • +
  • -

#6 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:38 PM

So did you just copy and paste and it didn't work? Did you try anything else? Do you get any errors in the console?
Was This Post Helpful? 0
  • +
  • -

#7 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:48 PM

This is my headerinclude template:

<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/prototype.js?ver=1603"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/general.js?ver=1603"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1600"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/jquery.cookie.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/sidebar.js"></script>
{$stylesheets}
<script type="text/javascript">
<!--
	var cookieDomain = "{$mybb->settings['cookiedomain']}";
	var cookiePath = "{$mybb->settings['cookiepath']}";
	var cookiePrefix = "{$mybb->settings['cookieprefix']}";
	var deleteevent_confirm = "{$lang->deleteevent_confirm}";
	var removeattach_confirm = "{$lang->removeattach_confirm}";
	var loading_text = '{$lang->ajax_loading}';
	var saving_changes = '{$lang->saving_changes}';
	var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
	var my_post_key = "{$mybb->post_code}";
	var imagepath = "{$theme['imgdir']}";
// -->
</script>
<script type="text/javascript" src="jscripts/thanks.js"></script>{$newpmmsg}

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> 

<script type="text/javascript">
/**
 * Modal Boxes JS
 *
 * @author Euan T. <[email protected]>
 * @version 1.0.0
 */

jQuery.noConflict();

jQuery(document).ready(function($)
{
    // Make the jQuery modal login redirect you back to the page you're currently on //
    $('#loginModal input[name="url"]').attr("value", window.location);
    // /Login redirect //

    // Modal Boxes //
    $('a[name="modal"]').on('click', function(event)
    {
        event.preventDefault();
        
        var target = $(this).attr('rel');
        
        // Set up the shadowing
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
        $('#mask').css({'width': maskWidth, 'height': maskHeight});
        $('#mask').fadeIn(1000);    
        $('#mask').fadeTo("slow", 0.8);  
        
        // Position the actual modal
        var winH = $(window).height();
        var winW = $(window).width();
        $(target).css('top',  (winH / 2) - ($(target).height() / 2));
        $(target).css('left', (winW / 2) - ($(target).width() / 2));
        $(target).fadeIn(2000); 
    });
    
    $('.modalBox a[rel="closeModal"]').on('click', function(event)
    {
        event.preventDefault();
        $('#mask, .modalBox').hide();
    }); 
    
    $('#mask').on('click', function ()
    {
        $(this).hide();
        $('.modalBox').hide();
    }); 
    // /Modal Boxes //
});
</script>


Is there anything clashing that is making it not save cookies?

This post has been edited by magicm00n: 05 August 2013 - 09:49 PM

Was This Post Helpful? 0
  • +
  • -

#8 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:53 PM

I don't see anywhere in your code on post #7 where you are including the
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/jquery.cookie.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/sidebar.js"></script>



It will not work if you don't include the proper code needed.
If you are adding these files please show that code.


Scratch that my browser decided not to load it all the first look.

This post has been edited by laytonsdad: 05 August 2013 - 09:55 PM
Reason for edit:: mistaken brower

Was This Post Helpful? 0
  • +
  • -

#9 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 09:56 PM

I have included all the files:

<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/prototype.js?ver=1603"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/general.js?ver=1603"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1600"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/jquery.cookie.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/sidebar.js"></script>
{$stylesheets}
<script type="text/javascript">
<!--
	var cookieDomain = "{$mybb->settings['cookiedomain']}";
	var cookiePath = "{$mybb->settings['cookiepath']}";
	var cookiePrefix = "{$mybb->settings['cookieprefix']}";
	var deleteevent_confirm = "{$lang->deleteevent_confirm}";
	var removeattach_confirm = "{$lang->removeattach_confirm}";
	var loading_text = '{$lang->ajax_loading}';
	var saving_changes = '{$lang->saving_changes}';
	var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
	var my_post_key = "{$mybb->post_code}";
	var imagepath = "{$theme['imgdir']}";
// -->
</script>
<script type="text/javascript" src="jscripts/thanks.js"></script>{$newpmmsg}

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> 

<script type="text/javascript">
/**
 * Modal Boxes JS
 *
 * @author Euan T. <[email protected]>
 * @version 1.0.0
 */

jQuery.noConflict();

jQuery(document).ready(function($)
{
    // Make the jQuery modal login redirect you back to the page you're currently on //
    $('#loginModal input[name="url"]').attr("value", window.location);
    // /Login redirect //

    // Modal Boxes //
    $('a[name="modal"]').on('click', function(event)
    {
        event.preventDefault();
        
        var target = $(this).attr('rel');
        
        // Set up the shadowing
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();
        $('#mask').css({'width': maskWidth, 'height': maskHeight});
        $('#mask').fadeIn(1000);    
        $('#mask').fadeTo("slow", 0.8);  
        
        // Position the actual modal
        var winH = $(window).height();
        var winW = $(window).width();
        $(target).css('top',  (winH / 2) - ($(target).height() / 2));
        $(target).css('left', (winW / 2) - ($(target).width() / 2));
        $(target).fadeIn(2000); 
    });
    
    $('.modalBox a[rel="closeModal"]').on('click', function(event)
    {
        event.preventDefault();
        $('#mask, .modalBox').hide();
    }); 
    
    $('#mask').on('click', function ()
    {
        $(this).hide();
        $('.modalBox').hide();
    }); 
    // /Modal Boxes //
});
</script>


What is probably causing it not to save cookies?

This post has been edited by magicm00n: 05 August 2013 - 09:58 PM

Was This Post Helpful? 0
  • +
  • -

#10 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 10:04 PM

It may be that that tutorial is out of date (07-07-2010) and the newer plugins for these may need a new jquery try jquery
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>


Was This Post Helpful? 0
  • +
  • -

#11 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 05 August 2013 - 10:15 PM

Still the same, funny how it is working on other forums. I have did this tutorial also: http://community.myb...ead-117646.html (jQuery login box). Could it be clashing?

This post has been edited by magicm00n: 05 August 2013 - 10:15 PM

Was This Post Helpful? 0
  • +
  • -

#12 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 06 August 2013 - 04:54 AM

I checked my console for errors it says "$.cookie is not a function".

How can I fix that?

This post has been edited by magicm00n: 06 August 2013 - 05:12 AM

Was This Post Helpful? 0
  • +
  • -

#13 BlueMelon   User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 06 August 2013 - 06:31 AM

View Postmagicm00n, on 06 August 2013 - 11:54 AM, said:

I checked my console for errors it says "$.cookie is not a function".

How can I fix that?


That means that the Cookie plugin is not being included. Make sure the file exists, and make sure it gets included.
http://plugins.jquery.com/cookie/
Was This Post Helpful? 0
  • +
  • -

#14 magicm00n   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 114
  • Joined: 01-March 12

Re: jQuery collapsible sidebar not saving cookies

Posted 06 August 2013 - 07:07 AM

I actually got it to work by changing the ".cookie" name to something else. But I don't understand why?
Was This Post Helpful? 0
  • +
  • -

#15 BlueMelon   User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: jQuery collapsible sidebar not saving cookies

Posted 06 August 2013 - 07:38 AM

View Postmagicm00n, on 06 August 2013 - 02:07 PM, said:

I actually got it to work by changing the ".cookie" name to something else. But I don't understand why?


What did you change it to?
Did you change the function definition it in the plugin file?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2