# Sortable\_element and new ul

**URL:** <https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285>\
**Category:** Rails\
**Created:** [September 21, 2010, 7:10am UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285 "2010-09-21T07:10:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 21, 2010, 7:10am UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285/1 "2010-09-21T07:10:31Z")

</div>

I have a sortable\_element, as a tree. I works great to add and remove  
from an existing sub list. But how do you create a new list under one  
element that doesn’t have a sub list before?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 21, 2010, 9:26pm UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285/2 "2010-09-21T21:26:11Z")

</div>

Not sure what you are asking, but maybe you could check into RJS and  
‘insert\_html’?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 21, 2010, 9:34pm UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285/3 "2010-09-21T21:34:34Z")

</div>

pepe wrote:

> Not sure what you are asking, but maybe you could check into RJS and  
> ‘insert\_html’?

- One
- Two
- Three

How do you drag Three so it’s placed under One, like:

- One
  - Three

- Two

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 21, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285/4 "2010-09-21T21:56:03Z")

</div>

I might be wrong, but I think that what you’re trying to do will need  
some manual work. I have never done what you’re trying to accomplish  
but if I were trying to do the same thing I would first think about  
making One a dropable element. The problem I can see, however, is hat  
the

 and 
 tags are going to be missing.

If I were in your position I would see if I can write some Javascript  
that inserts the

 tags around your - element if they are not  
already there when the element is dropped.

I’m sorry I can’t be of much help.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 21, 2010, 9:59pm UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285/5 "2010-09-21T21:59:33Z")

</div>

Sorry, not to make One a dropable element but to be able to receive  
dropable elements.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [September 21, 2010, 10:03pm UTC](https://www.ruby-forum.com/t/sortable-element-and-new-ul/195285/6 "2010-09-21T22:03:25Z")

</div>

pepe wrote:

> I might be wrong, but I think that what you’re trying to do will need  
> some manual work. I have never done what you’re trying to accomplish  
> but if I were trying to do the same thing I would first think about  
> making One a dropable element. The problem I can see, however, is hat  
> the
> 
> and 
> tags are going to be missing.
> 
> If I were in your position I would see if I can write some Javascript  
> that inserts the
> 
> tags around your - element if they are not  
> already there when the element is dropped.
> 
> I’m sorry I can’t be of much help.

Thanks. I do have a manual solution but I hoped for an existing  
solution.
