Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is UI object null when I manually trigger a sortable event?
    primarykey
    data
    text
    <p>I am writing a page where I want to trigger an event on a sortable manually (i.e. using the .trigger() method) in order to update the names &amp; ids of inputs which I need to bind to the form when the user makes a change that doesn't automatically fire the appropriate sortable events. I have two things which I found confusing that I would love to get a better understanding of if anyone knows and is willing to take the time.</p> <p>First point of confusion: I encountered a problem where the "manual" .trigger() method did not do anything if I defined the event within the .sortable() method (instead of appending an additional call to .bind()). I found numerous posts explaining the workaround, but its not clear to me if this is a feature or a bug. </p> <p>Second point of confusion: when I trigger the event manually, the "ui" object is null. It is defined when the event triggers normally. In my application I was able to work around this using selectors since what I really needed was ui.item anyway. But I would appreciate knowing if anyone else has encountered this, if I'm doing something wrong, etc. </p> <p>I set up a jsFiddle demonstrating both points of confusion: <a href="http://jsfiddle.net/nanzalone/TDWXs/" rel="nofollow">http://jsfiddle.net/nanzalone/TDWXs/</a></p> <p>The first is illustrated by the "receive" event. If you drag an item from the draggable to the sortable, you will see that the event fires properly. But pressing on the "Receive" button (which calls .trigger()) doesn't do anything.</p> <p>The second is illustrated by the "remove" event. Now the event fires, since I used .bind(), but the alert shows that using the "Remove" button to trigger the event results in a null ui object, while dragging an item into the trash to trigger the remove yields a non-null ui object.</p> <p>Thanks in advance for any pointers, and apologies for any faux pas I may have unwittingly committed (I'm still fairly new to jQuery).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload