I am using jQuery sortable and have two two lists that I am moving items from one to another. The first move works just fine with a double click. Now that it is in the second list, I want to allow users to remove items by clicking and hitting the delete key. My plan to do this is to have a click event trigger and decorate the list item with a class, and then when the delete key is hit, it will delete all items with that class. At this point, I am having issues getting the click event to take hold. Since I am creating the list items dynamic, I am using the on event keyword. My html for the second list looks like this:
<div id="CartContents" class="ui-widget-content">
<ul id="sortableArea" class="cartSortable">
</ul>
</div>
My js for trying to handle the click event looks like this:
$('.cartSortable li').on("click", function () {
alert('here');
$(this).toggleClass("selected");
});
The alert is there so that I know if it was hit. Let me know what you think is wrong or where my understanding is lacking.