Thursday 15 September 2011

php - nestedSortable on codeigniter -



php - nestedSortable on codeigniter -

i sorting function codeigniter pages "nestedsortable".. when click submit button doesnt find " {sortable: csortable}"

my code example: in views

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

in model file

public function save_order($pages) { if (count($pages)) { foreach ($pages $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>'; } } } }

in controller file

public function order_ajax() { // save order ajax phone call if (isset($_post['sortable'])) { $this->page_m->save_order($_post['sortable']); } //fetch pages $this->data['pages'] = $this->page_m->get_nested(); //fetch view $this->load->view('admin/pages/order_ajax', $this->data); }

i see error http://i57.tinypic.com/2uj6wpd.jpg

another error:

<?php echo get_ol($pages); function get_ol($array, $child = false) { $str = ''; if (count($array)) { $str .= $child == false ? '<ol class="sortable">' : '<ol>'; foreach ($array $item) { $str .= '<li id="list_' . $item['id'] . '">'; $str .= '<div>' . $item['title'] . '</div>'; //do have childrens ? if (isset($item['children']) && count($item['children'])) { $str .= get_ol($item['children'], true); } $str .= '</li>' . php_eol; } $str .= '</ol>' . php_eol; } homecoming $str; }

?> dont shows me on line 10 , 11 could't find name , title

"typeerror: parentitem null

pid = parentitem[2];"

looks type, wrong variable name. should csortable osortable?

php jquery codeigniter

No comments:

Post a Comment