2009-07-22 57 views
0

我使用jQuery的可调整大小从interface.eyecon.ro/docs/resizable为我正在处理的页面上的菜单。我需要设置一个cookie(plugins.jquery.com/project/Cookie)来存储菜单div的高度,以便div在每次重新加载页面时不会调整为原始CSS高度。从jQuery保存div高度的cookie可调整大小

我一直在尝试从http://www.shopdev.co.uk/blog/text-resizing-with-jquery/#comment-1044(我知道该代码中存在一些错误,但我已经得到该示例工作)中的代码,但现在我无法使其工作。

我的代码看起来像这样没有cookie的事情:

$(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'); 
     } 
    }); 
}); 

这是我第一次在计算器,我希望所有的好答案,我在这里也看到涉及到这个问题:)

感谢

回答

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 tly我需要什么。非常感谢您的快速和正确的答案! – 2009-07-22 18:36:28

相关问题