Could really use some help with troubleshooting my jQuery UI Todo List - it's just not

I've been working on a new project using jQuery UI to create a "to do list" application. So far, I've managed to get it up and running, but I'm having trouble displaying the tasks correctly in the designated div. Instead of showing up as a bar with a delete button and completed option, they are just appearing as plain text. Should I be including jQuery directly within the HTML as well?

If you'd like to see the current state of my app, check it out on this fiddle:

Todo List App FIDDLE

For simplicity, I'll only include the jQuery portion of the code here. The complete version can be found on the Fiddle link.

$("document").ready(function() {

$('#due_date').datepicker();
$('#add_task').button({ icons: { primary: "ui-icon-circle-plus" } }).click(function() { 
$('#new_task').dialog('open'); }); // end click
$('#new_task').dialog({ width: 350, 
                       height: 300, 
                        modal: true, 
                     autoOpen: false, 
                        close: function() { 
$('#new_task input').val(' '); /*clear fields*/
                }, buttons: {
    - Code continues from here -

Your help and guidance on resolving this issue would be greatly appreciated!

Answer №1

One issue arises with the click event in your code. You are simply transferring the .done span element to the completed list. Here's a revised approach:

$('#task_list').on('click', '.done', function () {
    var $this = $(this);
    var task_item = $this.parent('li');
    $this.detach();
    $('#completed_list').prepend(task_item);
    task_item.slideDown();
});

In this scenario, while the span.done is still removed, the entire li element is moved to the lower list.

The CSS also needs fixing, see updated code below:

#task_list li, #completed_list li {
    border: 1px solid rgba (0, 0, 0, 0.3);
    padding-top: .1em;
    line-height: 170%;
    margin-top: .2em;
}

The original code contained an extra curly brace after rgba, potentially impacting subsequent code as well.

EDIT The delete function requires some adjustments too. Here's the corrected version:

$('.sortlist').on('click', '.delete', function () {
    var task_item = $(this).parent('li');
    task_item.effect('puff', function () {
        $(this).remove();
    });
});

(Essentially, task_item was not properly defined).

Concerning the title, there appears to be an issue with duplicate id attributes in your HTML. Both elements have id="task". To fix this, you can modify your input tag like so:

<input type="text" name="task_title" id="task_title">

...and update your jQuery code to:

var task_name = $('#task_title').val();

By making these adjustments, the title should now display correctly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

avoid inserting into a specific field with a specific name

I am trying to add a picture next to a specific name, but I am facing issues as there is no option for inserting it. This is how my table looks: https://i.sstatic.net/RRaTb.png How can I insert a picture in front of a particular name? The content of my ...

Encountered an issue while trying to establish a connection between node.js and MongoDB

db connection error querySrv ENOTFOUND _mongodb._tcp.nodeapi.vlvom.mongodb.net (node:7720) UnhandledPromiseRejectionWarning: Error: querySrv ENOTFOUND _mongodb._tcp.nodeapi.vlvom.mongodb.net at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) (Us ...

What causes the error "searchInput" to be undefined?

Currently, I am facing an issue while attempting to search for individuals stored in an array within the Redux store. Whenever I try to execute a search, an error is triggered with the following message: Cannot read property 'searchInput' of und ...

Scraping data from Mass Lottery's website with the help of Beautiful Soup

I am currently using beautiful soup to extract all the keno numbers that have ever been drawn. While I have a good understanding of how to achieve this, I am encountering an obstacle. My goal is to retrieve both the game numbers and the corresponding winni ...

Creating an object positioned to the right side of a div (div:right) is a matter of using CSS positioning properties

While we are familiar with pseudo-classes like :before and :after, have you ever wondered why there is no nav ul li a:left or :right? Do you think it's achievable? I'm open to using HTML5, CSS3, and JavaScript to make it happen. ...

Using .load() function in jQuery prevents .mouseenter() from functioning properly on loaded content

I'm facing an issue with a page that has a navigation bar loading content from another page into a content div when a navigation item is clicked. The loaded content includes various divs, one of which has the style display: none. This hidden div sits ...

Restrict the number of button clicks to only once every 5 minutes

Similar Question: jquery disable a button for a specific time I am currently developing a PHP-based website. One of the features I want to implement is a button that can only be clicked once every five minutes by the user. After some research, I hav ...

Can someone provide guidance on incorporating a checkbox into my WordPress site?

I've created a toggle switch and now I want to incorporate it into my website, but I'm unsure of how to do so. The site uses the bbPress plugin on WordPress, and I would like users to be able to click the toggle switch when leaving a comment, wit ...

jQuery plugin that controls scrolling speed using the mousewheel

I am trying to replicate the header design of Google+ which includes a search bar that moves when scrolling. Specifically, when the user scrolls down, the search bar shifts to top:-60px and the second horizontal menu shifts from top:60px to top:0 becoming ...

How can I prevent dataTable resizing?

Is there a solution to prevent datatable resizing? For instance, when the default number of rows per page in the datatable is set to 10 rows. If you input 13 rows into the datatable, it will be divided into 2 pages - with 10 rows on the first page and 3 ro ...

Issue with JQuery on("submit") event not triggered upon first click

I'm currently using JQuery to check the size of an input field after submitting a form: <!DOCTYPE html> <html lang="en> <head> <title>Page 1</title> <meta charset="utf-8"/> <script src="https://ajax.google ...

The assertion that 'd3Ctrl' is not a valid function, but instead is undefined

Although several people have raised the same issue before and I've attempted their solutions, I still can't seem to resolve it. My problem involves using d3, but I keep encountering this error: app.js var app = angular.module('myApp', ...

Ways to declare a function within the events onMouseOver and onMouseOut

<div align="right" style="border:1 #FF0 solid; background-color:#999" onMouseOver="javascript: function(){this.style.backgroundColor = '#DDD';}" onMouseOut="javascript: function(){this.style.backgroundColor = '#999';}"> Register & ...

Modify the array value and access it outside of an asynchronous function

Is there a way to set values in an array from an asynchronous function and access it outside of that function's scope? I am working on a project where I need to randomize values in an array, so that I can assign images randomly to different div eleme ...

Mouseover Effect with Jquery Dropdown Menu

Is there a way to keep the child element open when hovering over PARENT1, and if you hover over PARENT2, its child opens while hiding the children of PARENT1? <ul id="nav"> <li>PARENT 1 <ul> <li>CHILD </li> <li ...

What are the steps for leveraging a proxy with NodeJS and Selenium?

While researching the topic on proxies in the documentation, I came across a method to set up a proxy while building a driver like this: var driver = new webdriver.Builder() .withCapabilities(webdriver.Capabilities.chrome()) .setProxy(proxy.manual ...

Creating an HTML form that dynamically populates a second select dropdown from a MySQL database, depending on the value selected

How can I dynamically populate the second select input in my HTML Form based on the value selected in the first select input? <form action="hidden/add_training.php"> <select name="race_type" id="race_ ...

What is the CSS/HTML code to position text at the bottom of an image overlay in a card design?

I've been attempting to modify the justify-content in the CSS class to "flex-end" and "end," however the text is not relocating to the bottom. My suggestion is that we concentrate on the img-overlay class, as that's where we adjust the position ...

Exploring Style Attribute Manipulation using vanilla JavaScript on Firefox

I searched for a similar question, but I couldn't find anything quite like it. I'm currently developing a JavaScript Slider plugin for various projects within our company. This requires me to manipulate styles on certain elements in the DOM. I&a ...

Putting the `href` attribute around an `input` of

Why is the <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href=" ...