0

这是网址: http: //itsun.ir/test/ 我英语不好的第一个借口,我想在我的 wordpress 主题中添加一个拖放布局,一切似乎都很好,但是当 li 元素移动到其他列时,javascript应该制作一个cookie并保存新位置以在其他时间加载,但它不能正常工作,当我在chrome浏览器的inspect元素中打开资源选项卡并将可排序项目移动到另一列时,在资源面板中出现错误这就是说:[未捕获的类型错误:对象#没有方法'join'],我已经更新了jquery,但它并没有使它正确,有人可以帮助我以正确的方式写这个吗?

      <script type="text/javascript">

$(document).ready(function(){

// Get items
function getItems(id)
{
    return $('#' + id + '-list').sortable('toArray').join(',');

Uncaught TypeError: Object # has no method 'join'

}

// Load items from cookie
function loadItemsFromCookie(name)
{
    if ( $.cookie(name) != null )
    {
        renderItems($.cookie(name),"wrapp");
    }
    else
    {
        alert('Cookie "' + name + '" is not set');
    }
}

// Render items
function renderItems(id, itemStr)
{
    var list = $('#' + id + '-list');
    var items = itemStr.split(',')

    for ( var i in items )
    {
        html = '<li class="sortable-item';

        if ( id == 'wrapp' )
        {
            html += ' columns';
        }
        html += '" id="' + items[i] + '"><div class="loader"></div></li>';

        list.append(html);

        // Load html file
        $('#' + items[i]).load('content/' + items[i] + '.html');
    }   
}

// Load items from cookie or defaults
var defaults = [];

defaults['splash'] = 'rightc,centerc,leftc';
var splashSource = ( $.cookie('splash-cookie') == null ) ? defaults['splash'] : $.cookie('splash-cookie');
renderItems('splash', splashSource);


// Splash (top)
$('#wrapp .sortable-list').sortable({
    forceHelperSize: true,
    forcePlaceholderSize: true,
    handle: '.label',
    containment: '#wrapper',
    opacity: 0.8,
    placeholder: 'placeholder',
    connectWith: '#wrapper .sortable-list',
    update: function(){
        $.cookie('splash-cookie', getItems('splash'));
    }
});



         });

       </script>
4

0 回答 0