Okay I am sure this is simple but I have gone over this a million times but can't figure out how to get the following to work. Previously I had been using live() which works absolutely fine. After moving to the "on" with the latest jQuery it no longer works. Below is a simplified version of my code. I have a search field, which on keyup returns a list of items with class "result" from an ajax call (search). I then want to target these returned elements.
$("input#search").on("keyup", function(e) {
// Set Timeout
clearTimeout($.data(this, 'timer'));
// Set Search String
var search_string = $(this).val();
// Do Search
if (search_string == '') {
$("ul#results").fadeOut();
}else{
$("ul#results").fadeIn();
$(this).data('timer', setTimeout(search, 100));
};
});
$("li.result").on("click", function(e) {
$(".selected").removeClass("selected");
$(this).addClass("selected");
});