Take the 2-minute tour ×

I've got a relatively complicated jQuery UI sortable, which I'm able to drag in elements from somewhere else. I'm using the following code, and am attempting to find the first element inside of what's been dropped with a class of editable, and trigger a click on it. This isn't working. I've thrown in some alerts and a console.log of ui.item[0].innerHTML returns an object with the correct DOM elements in it. So, I'm not quite sure what's going on here.

stop : function(event, ui){

Can anybody throw some of their wisdom my way? I'd greatly appreciate it. Just to note - if I click on the added element manually, it works as expected.

Thank you!

share|improve this question
did you try to click on it yourself? What's happening? –  Alexis Métaireau Aug 12 '11 at 20:40
Hey Alexis - yes, clicking on it works. Sorry about the confusion - I'll update the question. Thanks1 –  Connor Aug 12 '11 at 20:41
I suppose that calling "click()" directly on it doesn't change anything? –  Alexis Métaireau Aug 12 '11 at 20:47

2 Answers 2

up vote 1 down vote accepted

$(ui.item[0].innerHTML) creates a new element. So triggering an event on this element is useless.

Use $(ui.item[0]) instead.

share|improve this answer
It looks like you beat me by 37 seconds, what do we do now? –  nwellcome Aug 12 '11 at 20:47
Haha wow - you both rock! Thank you so much. I upvoted both, but I guesss since TheifMaster was ahead by 37 seconds, I've got to give it to them. Thank you, @nwellcome, though! –  Connor Aug 12 '11 at 20:49

I would guess that you want just $(ui.item[0]) and not $(ui.item[0].innerHTML) because innerHTML returns the HTML syntax of the element ui.item[0] (a string) and not references to the DOM nodes like you want.

share|improve this answer

Your Answer


