jQuery UI .trigger('click') not working
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, u开发者_C百科i){
$(ui.item[0].innerHTML).find('.editable').first().trigger('click');
}
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!
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.
$(ui.item[0].innerHTML)
creates a new element. So triggering an event on this element is useless.
Use $(ui.item[0])
instead.
精彩评论