Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery.ui sortable using a table and item:tr , placeholder difficulties

I would like to add support for sorting to tables I have created.

The placeholder I have implemented does not work at all in IE 7 when using item:TR . It works OK in FF.
I have tried the code on <UL\> and it performs correctly. It seems to be specific to tables and

I have researched through forums, and it appears that not a lot of people are using sorting with tables:

<style type="text/css">
  .dndPlaceHolder 
  {
    background-color:Red ;
    color:Red;
    height: 20px; 
    line-height:30px;
    border: solid 2px black;
  }    
  .dndItem
  {
    background-color: #c0c0c0;
    border:solid 1px black;
    padding:5px; 
  }
</style>

<script type="text/javascript" >
  $(function() {
    $("#myTable").sortable(
    {
      placeholder:'dndPlaceHolder',
      distance:15,
      items:'tr', 
      forcePlaceholderSize:true, 
      change : dndChange,
      update : dndUpdate
    });

    $("#myTable").disableSelection();

    $("#myList").sortable(
    {
      placeholder:'dndPlaceHolder',
      distance:15,
      items:'li', 
      forcePlaceholderSize:true, 
      change : dndChange,
      update : dndUpdate
    });

    $("#myList").disableSelection();

  });

  function dndChange(event,ui){

  }

  function dndUpdate(event,ui){
    var msg = '';
  }       
</script>

<table id='myTable' >
   <tr class='dndItem' id='1'>
      <td>0 Active - Active</td>
   </tr>
   <tr class='dndItem' id='2'>
      <td>1 Closed - Closed</td>
   </tr>
   <tr class='dndItem' id='3'>
      <td>2 OnHold - On Hold</td>
   </tr>
   <tr class='dndItem' id='4'>
      <td>3 Pending - Pending</td>
   </tr>
</table>
<BR>
<UL id='myList' >
  <li class='dndItem' id='1'>0 Active - Active</li>
  <li class='dndItem' id='2'>1 Closed - Closed</li>
  <li class='dndItem' id='3'>2 OnHold - On Hold</li>
  <li class='dndItem' id='4'>3 Pending - Pending</li>
</ul>

Can you help me with my requirements using the code I have provided or refer me to a guide demonstrating how this is done?

like image 550
greg Avatar asked Mar 26 '10 22:03

greg


1 Answers

Try this:

$("#myTable").sortable({
    ...
    'start': function (event, ui) {
        ui.placeholder.html('<!--[if IE]><td>&nbsp;</td><![endif]-->');
    },
    ...
};
like image 176
PetrP Avatar answered Sep 24 '22 21:09

PetrP