Using WordPress and working with Widgets. When I drag over a new widget to the sidebar (dragging over a list item from one sortable area to another)… I’m trying to bind the sortreceive
event so that I can apply some new rules to the elements within that new widget. But I’m not able to access that new list item and apply some event handlers.
$('div.widgets-sortables').bind( 'sortreceive', findToggles );
function findToggles(){
var featuredPostsWidget = $( 'div[id*="my_featured_posts-widget"]' );
console.log(featuredPostsWidget);
}
When I console.log()
each widget that exists on the page, I see all the old ones but not the new one I just dragged over. If I drag over another widget to the sidebar, it’ll now log the previous one I just dragged over, but not the new one.
The sortreceive
event seems to be firing just fine, but I can’t search for elements inside the new list item.
Any idea on how I can apply some event handlers to the new list item?