I have a Bootstrap dropdown button that is filled like the following:
<ul id="brandselection" class="dropdown-menu">
<li><a href='#'>Brand1</a></li>
<li><a href='#'>Brand2</a></li>
</ul>
Then I have the following JS code to dynamically create and fill a second dropdown button depending on the selection of the first:
$(function() {
$("#brandselection li").click(function(e){
e.preventDefault();
$("#model").load("getModelsUL.php?brand=" + encodeURI($(this).text()));
});
});
The resulting button code is basically the same as the one described above - and is created correctly.
But then, I use the exact same JS function (only the id of the div
being different) to react to a click on the second button - and it doesn't even enter the function.
I assume it is a problem with the DOM not being considered, since the second button was created after the initial DOM, but I don't know how to handle it correctly.