[Javascript] I have hit a brick wall
Terry Riegel
riegel at clearimageonline.com
Thu Sep 7 12:48:48 CDT 2006
Basically I have a bunch of Images that a user can drag one to
another location and when they drop the image it detects where they
dropped it and then it generates a list of the images that need to be
moved. I am now at the point where I need to move the images. I have
already implemented Scott's BubbleUpNodes() function and it seems to
be working so far. I am not sure if there is an easier way to do this.
Now I just need to communicate these changes back to the server via
AJAX.
Thanks,
Terry Riegel
On Sep 7, 2006, at 12:18 PM, Jonathan Buchanan wrote:
> On 9/7/06, Terry Riegel <riegel at clearimageonline.com> wrote:
>> Thanks Jonathan,
>>
>> That works for the array, but I need to swap out the objects
>> represented by the ID. I need soemthing similar to the swapNodes()
>> function you wrote yesterday.
>>
>> This is my humble (non-working) attempt so far.
>>
>>
>> function rippleNodes(a,k)
>> {
>> var placeHolder = document.createElement(k);
>> var i=document.getElementById(a[0])
>> for (x=0; x<a.length; x++)
>> {
>> if (x==0)
>> {
>> i.parentNode.replaceChild(placeHolder,i)
>> }
>> else
>> {
>> var n=document.getElementById(a[x])
>> var n1=document.getElementById(a[x-1])
>> n.parentNode.replaceChild(n1,n)
>> }
>> }
>> placeHolder.parentNode.replaceChild(i, placeHolder);
>> }
>>
>>
>> Terry
>
> The implementation of this really depends on the specifics of how the
> document is structured. Moving each and every node one at a time is a
> last resort, as you can structure your document in a way which makes
> it easy to manipulate as you desire.
>
> For example, if the nodes in question are arranged like so:
>
> parent
> |-- child1
> |-- child2
> |-- child3
>
> ...then moving child1 to the end is as simple as
> child1.parentNode.appendChild(child1).
>
> Similarly, if each node you're interested in is wrapped in its own
> container element, but the container elements are the only children of
> some common parent element, you do exactly the same, but operating on
> child1.parentNode instead of child1.
>
> Is for the same page as before?
>
> Jonathan.
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list