Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8290905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:56:57+00:00 2026-06-08T12:56:57+00:00

I dynamically set my innerHTML of my <ul> by using document.getElementById(myUL).innerHTML=<li…> The <li> I

  • 0

I dynamically set my innerHTML of my <ul> by using document.getElementById("myUL").innerHTML="<li...>

The <li> I create dynamically is not draggable by jquery. The static HTML however is.

How do I make the newly created dynamic HTML created using innerHTML directive to be draggable?

Here is some code:

function onAddTask() {
    var task = document.getElementById("task").value;

    for (i = 0; i < MAX_TASKS; i++)  {
        if (tasks[i] == null) {
            tasks[i] = task;
            break;
        }
    }

    /* construct HTML */
    var html = "<li class='ui-widget-content ui-corner-tr'>" +
            "<h5 class='ui-widget-header'>New Task</h5>" +
            "<a href='' onclick='return onCreateTask();'><img src='graphics/newtask.png' width='96' height='72'/></a>" +
            "<center>Create a new task</center>" +
            "</li>";
    for (i = 0; i < MAX_TASKS; i++) {
        if (tasks[i] != null) {
            html += "<li class='ui-widget-content ui-corner-tr ui-draggable' style='width: 96px; display: list-item;'><h5 class='ui-widget-hea
                + "<img src=graphics/task.png width=96 height=72>"
                + tasks[i]+"</li>";
        }
    }

    var todoList = document.getElementById("todo");
    todoList.innerHTML = html;

    tb_remove();

    return false;
}

And then in the HTML I have

<body>
<ul id="todo" class="todo ui-helper-reset ui-helper-clearfix">
    <li class='ui-widget-content ui-corner-tr ui-draggable' style='width: 96px; display: list-item;'><h5 class='ui-widget-header'>blah</h5>
        <img src=graphics/task.png width=96 height=72>
    </li>
    <li class="ui-widget-content ui-corner-tr">
        <h5 class="ui-widget-header">New Task</h5>
        <a href="" onclick='return onCreateTask();'><img src="graphics/newtask.png" width="96" height="72"/></a>
        <center>Create a new task</center>
    </li>
    <li class="ui-widget-content ui-corner-tr">
        <h5 class="ui-widget-header">Task</h5>
        <img src="graphics/task.png" width="96" height="72" />
        <center>Task Data</center>
    </li>
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:56:59+00:00Added an answer on June 8, 2026 at 12:56 pm

    In your onAddTask() function, add following lines just before line tb_remove();

    $("#todo li").draggable({
       helper : 'clone'
    });
    

    I have assumed that all required jquery+UI libraries are included.
    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to dynamically set (not create, it already has to exist) a
I am using jquery and c# to dynamically set a radiobuttonlist listitem to selected.
Is it possible to create a new List<T> where the T is dynamically set
I'm trying to dynamically create a set of labels in my XUL Runner application.
Is it possible to dynamically set a Spring MVC portlet:actionURL portlet:param using javascript? I
I'm using the iconField property of the Flex Tree to dynamically set the icon
I want to set timeouts dynamically in jQuery. The dynamically set timeout functions need
I'm using some annotations to dynamically set values of fields in classes. Since I
I'm using the getExcerpt() function below to dynamically set the length of a snippet
I'm using prepareForSeque:sender: to dynamically set the UITableView 's delegate and dataSource properties before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.