Unable to change the order in jQueryUI droppable and sortable, along with some persistent bugs that are proving difficult to resolve

I've managed to piece together most of the code, but I'm having a few issues that I can't seem to get working smoothly: -

  1. In the "Selected DVD's" area, I need to be able to change the order of these DVDs in this list only. For example, I want to change the order from 1,2,3 to 3,1,2.

  2. Items in the "Un-selected" area won't drag up into the selected dvds area

  3. If I click on the link at the top "add all unselected dvd's" and then click on the link "Remove all selected DVDs", it doesn't add them into the correct area at the bottom. However, if you click the "Remove all selected DVDs" link first, it works.

  4. Following #3, if I then add a new DVD at the top right, sometimes it adds loads of the same DVD?

Here is a functioning demo of what I have completed so far: http://jsfiddle.net/BFWzS/1/

There is more code available in the fiddle above ^

// Let the gallery items be draggable
$( "li", $gallery ).draggable({
  cancel: "a.ui-icon", // Clicking an icon won't initiate dragging
  revert: "invalid", // When not dropped, the item will revert back to its initial position
  containment: "document",
  helper: "clone",
  cursor: "move"
});

// Let the trash be droppable, accepting the gallery items
$trash.droppable({
  accept: "#gallery > li",
  activeClass: "ui-state-highlight",
  drop: function( event, ui ) {
    deleteImage( ui.draggable );
  }
});

Hopefully, someone can assist us with this issue,

Cheers

Answer №1

To improve the clarity of your question and get better responses, consider breaking down your issue into specific problems and asking them separately. Here are some tips to assist you:

  1. Take a look at JQuery Sortable

  2. Explore the Connect Lists option [EDIT] Your problem may not be reproducible in Chrome based on my testing on JSFiddle.

  3. If necessary, consider posting this as a distinct question or searching for existing duplicates

  4. If the previous steps do not resolve your issue, it might be worth raising a separate inquiry


For a more comprehensive answer, here is an example code snippet illustrating the usage of JQuery Sortable:

<div class="container">
    <div class="header">Selected DVDs</div>
    <ul id="gallery" class="dvdlist">
        <li>DVD 1</li>
        <li>DVD 2</li>
        <li>DVD 3</li>
    </ul>
</div>
<div class="container">
    <div class="header">Un-selected DVDs</div>
    <ul id="trash" class="dvdlist">
        <li>DVD 4</li>
        <li>DVD 5</li>
        <li>DVD 6</li>
    </ul>
</div>

$("#gallery").sortable({
    connectWith: "#trash"
});
$("#trash").sortable({
    connectWith: "#gallery"
});

To see this in action, click here.

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

Whenever I hover over a dropdown menu item, it suddenly stops functioning and I am forced to click in

I am facing an issue with my responsive dropdown menu that has 4 buttons, one of which opens a submenu (portfolio). The problem occurs when I accidentally click the 'portfolio' button, although it should only be triggered by a hover function. Thi ...

Eliminating Spaces within HTML Message Box

I'm facing an issue with a contact form on my website that consists of four text boxes. In the "message" box, which is an HTML textarea, random spaces appear every time the page loads. To make matters worse, the placeholder doesn't show up unless ...

Incorrect display of French characters in emails

Issues arise when sending emails with French characters, as they are not displaying correctly in the mail body. I made sure to include the following code in my HTML page: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> Despit ...

CSS3 Flexbox creating excess space on the right side

My website currently has a 4 column layout with each div set to a width of 25%, which is resulting in empty space on the right side. How can I adjust this layout to fill the entire screen width? https://i.sstatic.net/d0cJ6.png I have created a flexbo ...

Determining the selected number option with jquery

In my HTML page, I have a set of select menus as shown below: <label>Product Details</label> <select id="PD"> <xsl:for-each select="PRODUCT_DETAILS"> <option value="{DATA0}"><xsl:value-of selec ...

Adding images in Meteor is simple and effective

As a beginner in Meteor, I have recently begun my journey of learning the platform. I have stored all my images in the "/public" folder and they are named numerically (e.g., "1.jpg", "2.jpg", "3.jpg"). My goal is to add all these images to a collection ...

When clicked, the onClick feature will reduce the number each time instead of initiating the timer

Currently, I am working on a meditation application using React. As a starting point, I implemented a 25-minute countdown feature. The challenge I am facing is that the timer starts counting down each time the button is clicked, rather than triggering it ...

Continuously growing jQuery results population

I am facing an issue with a jQuery function that utilizes ajax to build an HTML string for populating the <ul></ul> feature. The problem arises when there is a link on the page that triggers a refresh, causing the added HTML content from the jQ ...

Can I set a default value for the image input field of type 'file' in CakePHP during editing?

I am facing an issue with editing images on my website admin panel. Each time I try to edit an image, I have to manually enter the image name, even when I only need to edit one image of type 'file'. Is there a way to automatically populate the de ...

Issue with Angular uploading a file and sending it as a POST request causing errors

I am currently working on an HTML form that allows users to upload files from the front-end to the back-end and perform various operations on them: <button mat-raised-button color="primary" type="button" style='margin-right:20px ...

Tips for making a dynamic active button using javascript

I'm trying to create a toggle button with eight buttons. When seven out of the toggle buttons are clicked, it should toggle between two classes and change its CSS styles. If the daily button is clicked, it should toggle the styles of the other seven b ...

Tips for uploading two different file types using a single PHP form

This is the layout of my form: <form action='uploadFile.php' method='POST'> <p>Choose an image:</p> <p style='font-size: 10px'>280x280px</p> ...

In Firefox, right floated elements vanish when utilizing columns

Utilizing the ol element with column-count and column-gap properties to organize the list into 2 columns, each list item contains a span element floated right. However, I am encountering an issue where the span element is not displayed for certain items li ...

Efficiently Extracting Data from an Array of Objects Using JQuery

What is the best method to extract information from the array below? How can I retrieve data categorized by specific categories? Is there a way to access only the key values? How do I retrieve just the data values? var main = [{ "key": "all", "dat ...

Issue with displaying submenu in dropdown menu

I need assistance with a project I am currently working on. You can view the project here Everything seems to be functioning properly, except for when I click on the button Click to expand, the sub-menu (Link 1, Link 2, ...) appears far left of the button ...

flash animation on an HTML webpage (fancy pop-up)

Hey, I'm interested in creating a similar effect to this: Check out this example >> Simply click on "Start PicLens Lite Slideshow PicLens". Did you notice how the swf/flash loads on top of the regular page? I want to achieve that :-D If there ...

HTML - Link to enable automatic printing of the page

Assignment: Develop a hyperlink (HTML <a> tag) that triggers the printing of the webpage without the user manually pressing CTRL + P. My search for information on this topic has not yielded a definitive answer. Some sources suggest using JavaScript ...

Show the HTML code within the form with the identifier html-editor-form

I have four different sections which are displayed when the corresponding icon is clicked. The area labeled as visual-editor contains multiple HTML values. I am looking to showcase all the HTML values within the visual-editor class under the html-editor ...

My website is being cut off

After creating this website with a viewport setup, I noticed that it is not fully visible on certain screens. When viewed on a CRT monitor at 800x600 desktop resolution or lower than 1280x800, such as on mobile devices, the content gets clipped. Is there a ...

Easiest Way to Implement jQuery AJAX

Is there a way to continuously update the user's status as ACTIVE on the server every minute without requiring a response? setInterval(function() { $(document).load('path/to/keep-user-active.php'); }, 60000); The PHP script will handle ...