jquery - Can't make jQ UI accordion work w/ cookie after jQ/UI upgrade -
i have piece of code, uses cookies create jquery accordion selection persist trough refresh
the problem works jquery ui 1.7.2 , jquery javascript library v1.4.1
if update jquery ui - v1.10.0 , jquery javascript library v1.9.0, doesn't persist anymore (no errors, not persisting accordion selection across page loads)
here code
$( function() { var cookiename = 'stickyaccordion'; $( '#accordion' ).accordion( { active: ( $.cookies.get( cookiename ) || 0 ), change: function( e, ui ) { $.cookies.set( cookiename, $( ).find( 'h3' ).index ( ui.newheader[0] ) ); } } ); } );
in html have
<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery-ui.js"></script> <script type="text/javascript" src="jquery.cookies.js"></script>
cookie provided http://code.google.com/p/cookies/
the cookie code fine, jquery ui accordion api has changed upgrade such change
no longer valid event--it has been changed activate
. can adjust activate
method's body more efficient re-querying headers every time.
here live demo of new api in use: http://jaaulde.com/test_bed/stickyaccordionnewapi/
and here specific js:
$(function () { var cookiename = 'stickyaccordionnewapi', $accordion = $('#accordion'), $headers = $accordion.children('h3'); $accordion.accordion( { active: ($.cookies.get(cookiename ) || 0), activate: function (e, ui) { $.cookies.set(cookiename, $headers.index(ui.newheader)); } }); });
it's not quite drastic alter ui tabs underwent, alter nonetheless.
jquery jquery-ui cookies accordion jquery-accordion
No comments:
Post a Comment