Community & Support

Help using jQuery UI Module -> Sortable elements

Hi all !
First of all, my english level is bad, i'm spanish.

The trouble is that, i want to use the jQuery UI Module to sort a list of elements that layout with my theme function. I don't know what drupal function does internally.

Here the code i use to layout the database items :

<?php
function metalinks_list() {
    global
$user;
   
//drupal_set_title(t('Links associats a: @name', array('@name' => $account->name)));
   
$max = 20;
   
$sql = 'SELECT lid,name,link FROM {metalinks} WHERE uid = %d';
   
$header = array(
    array(
'data' => t('Title'), 'field' => 'name'),
    array(
'data' => t('Operations'), 'colspan' => 2)
      );
     
$result = pager_query(db_rewrite_sql($sql . tablesort_sql($header)), $max, 0, $count_query = NULL, $user->uid);
   
$rows = metalinks_build_rows($result);

   
$output = '';
     
$output .= theme_metalinks_list($header, $rows, $max);
      return
$output;
}
 
function
metalinks_build_rows($result) {
  global
$user;
 
$rows = array();
  while (
$row = db_fetch_object($result)) {
       
$may_edit = TRUE;
       
$may_delete = TRUE;
       
$rows[] = array(
           
l($row->name,$row->link),
           
$may_edit ? l(t('edit'), "metalinks/edit/$row->lid") : '',
           
$may_delete ? l(t('delete'), "metalinks/delete/$row->lid") : ''
     
);
  }
  return
$rows;

 
function
metalinks_theme() {
  return array(
   
'metalinks_list' => array(
     
'arguments' => array('header' => array(), 'rows' => array(), $max = 50),
    ),
  ); 

 
function
theme_metalinks_list($header, $rows, $max) {
  if (
$rows) {
   
$pager = theme('pager', NULL, $max, 2);
    if (!empty(
$pager)) {
     
$rows[] = array(array('data' => $pager, 'colspan' => 3));
       
jquery_ui_add('ui.sortable');
    }
   
$output .= theme('table', $header, $rows);
  }
  else {
   
$output = t('Tu espacio está vacío.');
  }
  return
$output;
}
?>

http://img228.imageshack.us/img228/2779/listav.png

How can i use the Jquery and my theme output both??

Thank you very much !

Comments

any body use jQuery? i can't

any body use jQuery?
i can't believe anybody use....

nobody click here