Hi, I have a bootstrap popup menu that automatically populates from the database. I try to get an event when I click on one of the items in the menu. I tried
$("body").on("click", ".ddBtnClick", function(event) { console.log("Is it working? Yes!!"); });
with ".ddBtnClick" being the class assigned to each of the elements in the list. but nothing happened. Here is the code to populate the list from the database.
$.getJSON("http://jeremiah.abrahamott.com/DadsCarsObjects.txt", function(data){ $.each(data.aaData, function(i, option){ $("#dropdownfill").append($('<li/>').append($('<a/>').attr("id", option.Year).attr("href", "#").attr("tabindex", "-1").addClass("ddBntClick").text(option.Make))) }); });
Here is the html for the dropdown.
<div class="row" style="margin-left:50px;"> <div class="span3"> <div class="btn-group"> <a class="btn dropdown-toggle" data- toggle="dropdown" href="#">Make <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" id="dropdownfill"> </ul> </div> </div> </div>
source share