jQuery Mobile Panel / jQuery Cookies -



jQuery Mobile Panel / jQuery Cookies -

i creating jquery mobile site (1.4.2) , using panels. have set script open panel on load if window width gt 768. works fine exception of users close panel , want maintain closed while doing tasks, thinking of setting cookie value when close panel , run script opens panel if cookie not set.

for initial script have next , -

<script> $(document).on('pageinit', function() { var width = $(window).width(); if(width > 768) { $('##bluebuttonspanel').panel('open'); } }); </script>

using jquery cookie plugin setting cookie -

<script> $(document).on('pageinit', function() { if( $('.ui-panel').hasclass('ui-panel-closed') == true ) { $.cookie('panel','is-hidden'); } else { $.cookie('panel','is-visible'); }; }); </script>

where confused trying alter value of cookie when click tab panel, if panel cookie value set 'is-hidden', not run initial open script. don't know how alter value of cookie on click , test status on open script...

$('a#tab').click(function () { if ($.cookie('panel', 'is-visible')){ ...?

any help appreciated! hope posting correctly because haven't posted in long time! tia!

i worked problem while , came solution seems working far.

i head of calling page checking see if cookie exists named 'panel' value of 'is-hidden'. if window width greater 768 , cookie value not equal 'is-hidden' open panel automatically.

$(document).on('pageinit', function(){ var width = $(window).width(); if(width > 768 && ($.cookie('panel') != 'is-hidden')) { $('#bluebuttonspanel').panel('open'); } });

in bottom of page setting cookie when user clicks tab looking @ current class of panel when user clicks tab - if panel open , user clicks on tab, state of panel closed , cookie value set 'is-hidden.'

$('#tab').click(function () { if( $('.ui-panel').hasclass('ui-panel-open') == true ){ $.cookie('panel','is-hidden'); } else { $.cookie('panel','is-visible'); } });

i want remember cookie value per session @ end of session clearing value of cookie , setting 'null.'

$.cookie("panel", null);

in way utilize can navigate through site panel closed if desired, without opening automatically on each request, , keeps closed on page load smaller screens (which default behavior).

it working expected! improvements , ideas welcome!

jquery jquery-mobile cookies

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -