2014-10-10 18 views
0

我整理與笨功能與「nestedSortable」頁面..當我點擊提交按鈕,它沒有找到「{排序:cSortable}」nestedSortable對笨

我的代碼示例: 的觀點

$(document).ready(function() { 
    $.post('<?php echo site_url('admin/pages/order_ajax'); ?>', {}, function(data) { 
     $('#orderResult').html(data); 

    }); 

    $('#save').click(function() { 
     oSortable = $('.sortable').nestedSortable('toArray'); 
     $.post('<?php echo site_url('admin/pages/order_ajax'); ?>', {sortable: cSortable}, function(data) { 
      $('#orderResult').html(data); 
     }); 
    }); 
}); 

模型文件

public function save_order($pages) { 
    if (count($pages)) { 
     foreach ($pages as $order => $page) { 
      dump($page); 
      if ($page['item_id'] != '') { 
       $data = array('parent_id' => (int) $page['parent_id'], 'order' => $order); 
       $this->db->set($data)->where($this->_primary_key, $page['item_id'])->update($this->_table_name); 
       echo '<pre>' . $this->db->last_query() . '</pre>'; 
      } 
     } 
    } 
} 

控制器文件

public function order_ajax() { 

     // save order from ajax call 
     if (isset($_POST['sortable'])) { 
      $this->page_m->save_order($_POST['sortable']); 
     } 
    //fetch all pages 

    $this->data['pages'] = $this->page_m->get_nested(); 
    //fetch view 

    $this->load->view('admin/pages/order_ajax', $this->data); 
} 

我看到這個錯誤http://i57.tinypic.com/2uj6wpd.jpg

另一個錯誤:

<?php 
echo get_ol($pages); 

function get_ol($array, $child = FALSE) { 
    $str = ''; 
if (count($array)) { 
    $str .= $child == FALSE ? '<ol class="sortable">' : '<ol>'; 

    foreach ($array as $item) { 
     $str .= '<li id="list_' . $item['id'] . '">'; 
     $str .= '<div>' . $item['title'] . '</div>'; 

     //do we have childrens ? 
     if (isset($item['children']) && count($item['children'])) { 
      $str .= get_ol($item['children'], TRUE); 
     } 

     $str .= '</li>' . PHP_EOL; 
    } 
    $str .= '</ol>' . PHP_EOL; 
    } 
    return $str; 
} 

> ,所以我不得到它表明我在第10行和11便無法?找到名稱和標題

「TypeError:parentItem is null

pid = parentItem [2];「

回答

0

看起來像一個類型,錯誤的變量名稱。 cSortable是否應該是oSortable?

+0

Jap它的工作給我,但另一個錯誤,當我把創建的頁面內其他頁頂.. http://i60.tinypic.com/v7cah3.jpg – user3447137 2014-10-11 09:44:53