Link to home
Start Free TrialLog in
Avatar of dshrenik
dshrenikFlag for United States of America

asked on

Dojo - Add a ul to a ul

I have a ul on my page with a dojoAttachpoint. I am creating a ul dynamically. I now want to add this ul dynamically to the first ul. Please let me know how this can be done.

Thanks!
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

If you are trying to 'nest' a ul in another one, you need to put it in an 'li' under the first one.

<ul>
<li>content</li>
<li>
      <ul>
      <li>more content</li>
      </ul>
</li>
</ul>

Open in new window

Avatar of dshrenik

ASKER

Can you tell me how I can do this dynamically with Dojo? Thanks!
No, never heard of Dojo.
ASKER CERTIFIED SOLUTION
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi dshrenik,
This might do it too: dojo/html provides useful utilities for managing HTML.

Possibly something like this:
require(["dojo/html", "dojo/dom", "dojo/on", "dojo/domReady!"],
function(html, dom, on){
  on(dom.byId("setContent"), "click", function(){
    html.set(dom.byId("content"), "<ul><li>Item 1></li><li>Item 2</li></ul>");
  });
});

<button type="button" id="setContent">Set Content</button>
<div id="content">I haven't been replaced.</div>

Open in new window

Alan ";0)