Is row_position a row number in the table? Those numbers would change when
you delete a row. Or is it a value that you increment every time you add a
row (independent of the position in the table)? That would work - but you
wouldn't have a way to loop through this object sequentially.

Dave, I think we need to know more about what you're doing with that data to
suggest a solution. But here's another idea: If the problem is your array
getting out of sync when you delete a row, simply use [].splice() to delete
the corresponding array element, e.g. if you are deleting row 'n', use
array.splice(n,1) to delete the element.

You can also use .splice() to insert elements in an array, or delete and
insert elements at the same time. It's a very handy function.

-Mike

> From: Nicolas R
> 
> instead of using an array you could use a key/value object.
> then you can do something like
> 
> var o = {}
> o[row_position] = [row_data]
> 
> then when you remove a row you do
> 
> delete o[row_position]
> 
> you could get the row's position from the drag&drop callback 
> I assume, but even if thats not the case its pretty straight 
> forward using jquery i guess.
> 
> On Nov 24, 5:40 pm, daveyoi <[EMAIL PROTECTED]> wrote:
> > Hello Everyone,
> >
> > I am new to jquery and am using it in a project to develop 
> a PHP based 
> > Mysql report generator. My question is not 100% jquery but more on 
> > application design?
> >
> > I have a bunch of list items that I can drag and drop (thanks to
> > jquery) on to a workspace - on dropping I create a 
> <TH></TH> elelment 
> > with the value of the list item and an image which has a .click() 
> > attached with a call back to a remove(). - This all works 
> as expected 
> > and really demonstrates how after just a couple of hours 
> how powerfull 
> > jquery is.
> >
> > The hard part that I just cant get my head round is I need 
> the value 
> > and position of each item dropped onto the page stored 
> somehow. I have 
> > been using a bog standard js array and just pushing the new 
> value into 
> > the array on the drop callback but if I remove one of the <TH></TH> 
> > then my array keys become out of sync.
> >
> > Any suggestions on how best to approach this - I am primarily a PHP 
> > developer and have been thinking of using Ajax to store the 
> data in a 
> > temp table but this seems a little longwinded.. js gurus your ideas?
> >
> > Thanks - and hope I can repay the favour some time.
> >
> > Dave
> 

Reply via email to