Here is my snippet:

var myIndex = $j("#show_medication").parents("tr")...

#show_medication is a form element.
parents("tr") is the row containing the element
Now I want to get the rowIndex

Once I have the rowIndex property I would call the moveRow function as
follows:

$j("#show_medication").parents('table:eq(0)').moveRow(myIndex, myIndex-
someNumber, true)

Mike

On Aug 2, 1:46 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Mike Miller wrote:
> > Thanks for this...it truly is amazing what jquery can do.  A quick
> > question for you though regarding the index property.  If I want to
> > make this more dynamic...do you know how I would find out the value of
> > the rowIndex property for the table row I want to move?
>
> Get it directly from the tr element:
>
> var rowIndex = $('tr')[0].rowIndex;
>
> That's shorter than using all jQuery:
>
> var rowIndex = $('tr').attr('rowIndex');
>
> The plugin could of course be changed to take tr elements instead of
> passing indices and you don't need to handle the rowIndex:
>
> jQuery.fn.moveRow = function(from, to, useBefore) {
>      var trs = this.find(">tr");
>      $(from)['insert' + (useBefore && 'Before' || 'After')](to);
>      return this;
>
> };
>
> Usage:
>
> var from = $('tr:eq(3)'); // 4th row
> var to = $('tr:eq(0)'); // 1st row
> $('tbody').moveRow(from, to); // insert 4th row after 1st row
>
> Is that what you need?
>
> --Klaus

Reply via email to