2009-07-22 13 views
0

私が取り組んでいるページのメニューにinterface.eyecon.ro/docs/resizableからサイズ変更可能なjQueryを使用しています。私はメニューdivの高さを保存するためにcookie(plugins.jquery.com/project/Cookie)を設定する必要があります。その結果、divはすべてのページのリロード時に元のCSSの高さにリサイズされません。jQueryのサイズ変更可能なクッキーにdivの高さを保存

私はコードをhttp://www.shopdev.co.uk/blog/text-resizing-with-jquery/#comment-1044から適応させようとしてきました(私はそのコードにいくつかの誤りがありますが、その例はうまくいくと思いますが)しばらくの間、

私のコードは、クッキー事なしに、次のようになります

$(document).ready(function() { 
    $('#resizeMe').Resizable({ 
     maxHeight: 600, 
     minHeight: 24, 
     handlers: { 
      s: '#resizeS' 
     }, 
     onResize: function(size) { 
      $('#content_two', this).css('height', size.height - 6 + 'px'); 
      $('#content').css('padding-top', size.height + 44 + 'px'); 
     } 
    }); 
}); 

これはstackoverflowの上の私の最初の時間であり、私は私がここで見てきたすべての良い答えもこの質問に来ることを願っています:)

おかげ

答えて

1

あなたは、おそらくこのような何かを試すことができます。

$(document).ready(function() { 

    var cookieName = 'divHeight'; 

    //On document ready, if we find height from our cookie, 
    //we set the div to this height. 
    var height = $.cookie(cookieName); 
    if(height != null) 
     $('#resizeMe').css('height', height + 'px'); 


    $('#resizeMe').Resizable({ 
     maxHeight: 600, 
     minHeight: 24, 
     handlers: { 
       s: '#resizeS' 
     }, 
     onResize: function(size) { 
       $('#content_two', this).css('height', size.height - 6 + 'px'); 
       $('#content').css('padding-top', size.height + 44 + 'px'); 
       //I am assuming that onResize is triggered when user has finished resizing the DIV. If yes, you can store this div height in the cookie. 
       $.cookie(cookieName, size.height); 
     } 
    }); 
}); 
+0

これはexacました私が必要としていたものです。迅速で正確な回答をいただきありがとうございます! –

関連する問題