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 8300097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:25:28+00:00 2026-06-08T16:25:28+00:00

I have a setup where I want to conditionally revert an element that is

  • 0

I have a setup where I want to conditionally revert an element that is being dropped

(I tried using the accept event, but that proved to run far too often for practical purposes. – not only that, its use cancels other events.)

EDIT: its actually not that it runs far too often, but rather that.. when it fires, $(this).attr('id') becomes incorrect upon revisiting hovered over elements. http://jsfiddle.net/UvByv/1/

For example above:

  1. grab a piece and hover over various squares.
  2. note the square number it hovers over. it doesn’t always update as it should.

You will see that the square elements are numbered. When a square is revisited, $(this).attr('id') apparently stops being updated on a timely basis

*What I am trying to do is to conditionally “toggle droppability”, reading the DOM while hovering over an element. it appears that accept doesn’t entirely sync with the rest of the DOM for my purposes. *

The reason is, as you will see with my example, being squares with chess pieces, depending on what square a piece is over at a particular point in time., I might not want to allow a drop. Other times, I would want to.

  • 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-08T16:25:30+00:00Added an answer on June 8, 2026 at 4:25 pm

    If I understand this correctly, you want to toggle droppability based not only on whether or not the space is currently occupied, but also if the current move is a valid chess move (after all, some valid chess moves involve one piece taking the place of another). Is this true? If so, I would think using a complex accept function would, in fact, be the right strategy.

    This function receives two pieces of critical information: the piece being dragged (the sole “el” argument) and the space potentially being dragged to (which is the function’s this variable). You noted that the accept function is called multiple times, and this is by design: as you can see in the jQuery UI source code, when a draggable is being dragged, the accept function will be evaluated for each droppable space on the board. This means that when you start moving a piece, each droppable space will calculate whether or not it can accept the piece.

    I understand that you want to evaluate this “on the fly” as a piece passes over another square, but is the overhead of calculating it in advance causing noticeable performance issues? If not, I would go with accept.

    Edit: I’ve created a jsFiddle that demonstrates how to use .append to move the piece from square to square: http://jsfiddle.net/58t7L/3/

    Edit by Kevin: Accepted because in chat Matt helped to stratify the issue to show that my method of using $(this) in accept is not exactly geared toward how accept is intended to be used. .over: would be for the process I was describing and using, while ‘accept’ really demands a different process, as it evaluates all droppables at once. Chat link is in comment below

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

Sidebar

Related Questions

I have setup file of winform. but i want to change my icon how
I have a Inno Setup project that I want to check if the application
I want to have a good test setup but, I can't find a way
I have some bindings that are setup as singletons. I want them to always
I have this setup that works perfectly when using http. A silverlight 3 client
Hey guys I have setup Nivo slider to my specification, but what I want
I have setup a Continuous Integration environment using CruiseControl.Net. I want to know how
I have a very basic JNA test setup that I want to use to
I have a setup project in c#. i want that setup run 2 exe
We have replication setup on a database and is working fine. Now we want

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.