`
hb_keepmoving
  • 浏览: 228869 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

转jquery sortbale cookie保存排序。。

 
阅读更多
<div class="demo">  
  
<div class="column">  
  
 <div class="portlet">  
  <div class="portlet-header">Feeds</div>  
  <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>  
 </div>  
   
 <div class="portlet">  
  <div class="portlet-header">News</div>  
  <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>  
 </div>  
  
</div>  
  
<div class="column">  
  
 <div class="portlet">  
  <div class="portlet-header">Shopping</div>  
  <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>  
 </div>  
  
</div>  
  
<div class="column">  
  
 <div class="portlet">  
  <div class="portlet-header">Links</div>  
  <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>  
 </div>  
   
 <div class="portlet">  
  <div class="portlet-header">Images</div>  
  <div class="portlet-content">Lorem ipsum dolor sit amet, consectetuer adipiscing elit</div>  
 </div>  
  
</div>  
  
</div>  
  
js代码:  
  
 <mce:script type="text/javascript"><!--  
 $(function() {  
  $(".column").sortable({  
   connectWith: '.column'  
  });  
  
  $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")  
   .find(".portlet-header")  
    .addClass("ui-widget-header ui-corner-all")  
    .prepend('<span class="ui-icon-minusthick ui-icon"></span>')  
    .end()  
   .find(".portlet-content");  
  
  $(".portlet-header .ui-icon").click(function() {  
   $(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");  
   $(this).parents(".portlet:first").find(".portlet-content").toggle();  
  });  
  
  $(".column").disableSelection();  
 });  
   
// --></mce:script>  
  
下面是保存代码  
 
    <mce:script type="text/javascript"><!--  
function MadeDiv()  
{  
if (!$.cookie("dao_list")) {  
                $.cookie("dao_list", "c1:0@1@2@3@4@|c2:5@6@7@8@9@");   
            }  
            var list = $.cookie("dao_list");   
            var arrColumn = list.split('|');  
             $.each(arrColumn, function(m, n) {  
                var elemId = n.split(':')[0];   
                var arrRow = n.split(':')[1] ? n.split(':')[1].split('@') : "";   
                $.each(arrRow, function(m, n) {  
                    if (n) {  
                        $("#" + elemId).append($("#dao_hang" + n).attr('id', n))  
                    }  
                });  
             })  
               
  $(".column").sortable({  
   connectWith: '.column',  
   handle:'.portlet-header',  
   cursor: 'move',  
   stop:saveLayout  
  });  
         
     
  $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")  
   .find(".portlet-header")  
    .addClass("ui-widget-header ui-corner-all")  
    .prepend('<span class="ui-icon ui-icon-closethick" title=\"点击删除导航\"></span>')  
    .end()  
   .find(".portlet-content");  
  
  $(".portlet-header .ui-icon").click(function() {  
            var this_box=$(this).parent().parent().closest("div").remove();  
            saveLayout();  
  });  
    $(".column").disableSelection();  
       $( ".column" ).sortable( { forcePlaceholderSize: true } );  
}  
function saveLayout() {  
                var list = "";  
                $.each($(".column"), function(m) {  
                    list += $(this).attr('id') + ":";  
                    $.each($(this).children(".portlet"), function(d) {  
                        list += $(this).attr('id') + "@";  
                    })  
                    list += "|";  
                })  
                $.cookie("dao_list",list, {expires: 300});  
}  
function moren()  
{  
                $.cookie("dao_list","c1:0@1@2@3@4@|c2:5@6@7@8@9@", {expires: 300});  
                window.location.reload();  
}  

 

分享到:
评论

相关推荐

    jquery.cookie.js下载

    jquery cookie.js 官方下载,一款优秀的 jquery 插件,提供了非常轻量级、简单、实用的操作 cookie 的方法,包括读写、删除等操作,jquery cookie 路径,jquery cookie 时间,jquery cookie 有效期,jquery cookie ...

    jquery1.4.2.js和jquery.cookie.js

    《jQuery 1.4.2与jQuery Cookie插件详解》 在Web开发中,JavaScript库jQuery因其简洁的语法和强大的功能而备受青睐。本篇将深入探讨jQuery 1.4.2版本及其与jQuery Cookie插件的使用,帮助开发者更好地理解和应用这...

    jquery.cookie.js包

    `jquery.cookie.js`是jQuery的一个扩展插件,它使得在Web应用中管理和操作Cookie变得更加简单。本篇文章将深入探讨`jquery.cookie.js`包及其在实现“记住密码”功能中的应用。 首先,我们来了解什么是Cookie。...

    jquery.cookie.js,jquery.min.js

    2. **jQuery Cookie Plugin**: `jquery.cookie.js`是jQuery的一个插件,用于处理浏览器的Cookie。这个插件允许开发者方便地读取、设置和删除Cookie,这对于实现用户会话管理、个性化设置等功能非常有用。 3. **...

    jquery管理cookie和form的js

    在这个“jquery管理cookie和form的js”压缩包中,我们有两个关键的脚本文件,分别是用于管理cookie的jQuery插件和处理表单(form)操作的jQuery插件。 首先,我们来详细了解一下jQuery如何管理cookie。 **jQuery ...

    cookie设置插件jquery.cookie.min.js

    cookie设置插件jquery.cookie.min.js 文章《javascript设置cookie高级篇可跨域访问》https://blog.csdn.net/cplvfx/article/details/117822956

    jquery 设置cookie、删除cookie、获取cookie

    在前端开发中,通过 JavaScript 操作 Cookie 是一种常见的需求,尤其是为了实现用户状态的持久化存储或网站配置的保存等场景。jQuery 提供了一个非常方便的方式来处理这些操作,本文将详细介绍如何利用 jQuery 和其...

    JQuery对cookie操作

    例如,当用户勾选“记住我”时,可以将用户ID保存在Cookie中: ```javascript // 勾选"记住我"时 if (checkboxRememberMe.checked) { $.cookie('userID', userId, { expires: 30 }); } // 检查登录状态 function ...

    jQuery插件Cookie操作jQuery.Cookie

    jQuery操作cookie的插件,大概的使用方法如下$.cookie('the_cookie'); //读取Cookie值$.cookie(’the_cookie’, ‘the_value’); //设置cookie的值$.cookie(’the_cookie’, ‘the_value’, {expires ‘/’, domain ...

    jquery下cookie插件使用

    在Web开发中,Cookie是客户端存储机制的一种,被广泛应用于用户身份验证、保存用户偏好等场景。然而原生JavaScript操作Cookie较为繁琐,为此,jQuery社区提供了jQuery Cookie插件,极大地简化了Cookie的创建、读取与...

    jquery.cookie.min.js

    最新的JQUERY.COOKIE.MIN.JS

    jquery.cookie.js

    Cookie是由服务器端生成,发送给User-Agent(一般是浏览器),浏览器会将Cookie的key/value保存到某个目录下的文本文件内,下次请求同一网站时就发送该Cookie给服务器(前提是浏览器设置为启用cookie)。 例如购物...

    jquery.cookie.js插件源码绿色工具

    在标题提到的“jquery.cookie.js插件源码绿色工具”中,我们关注的是如何使用该插件来保存用户的主题选择,以便他们在下次访问时仍能看到他们之前选择的主题。 ### 1. jQuery Cookie基本用法 首先,确保你的项目中...

    jquery-cookie(Jq取cookie必备).rar

    《jQuery Cookie:轻松实现JavaScript中的Cookie操作》 在Web开发中,Cookie是一种常见的数据存储机制,用于在客户端保存用户信息、设置或跟踪用户行为。jQuery库的扩展插件jQuery Cookie则为开发者提供了一种简单...

    jquery.cookie实现json添加、查询、删除

    使用jQuery.cookie插件,我们可以将JSON对象序列化为字符串并保存到Cookie。首先,创建一个JSON对象: ```javascript var myJson = { key1: 'value1', key2: { subKey1: 'subValue1', subKey2: 'subValue2' ...

    jquery-cookie

    **jQuery Cookie插件详解** jQuery Cookie是一个非常实用的JavaScript库,它为jQuery提供了一种简单的方式来操作浏览器的Cookie。在Web开发中,Cookie是用于存储客户端数据的一种机制,它可以跟踪用户的浏览行为、...

    jquery-cookie-master.jar

    《深入理解jQuery Cookie机制及其应用》 在Web开发中,数据的存储是不可或缺的一部分,而Cookie作为客户端存储数据的一种方式,被广泛应用于各种场景。jQuery库的jQuery Cookie插件简化了JavaScript操作Cookie的...

Global site tag (gtag.js) - Google Analytics