I have three different divs, div 1, div 2 and div 3.
Step 1: I will display few pre-defined number of buttons in div 1 which when clicked, will populate dynamic content into div 2.
Step 2: This dynamic HTML content contains few random number of buttons which when clicked should show their respective content in div 3.
I am using String Template 4 to populate these html files. So I have means to get the necessary information into page and also identify each button by a unique identifier. Since Step 1 deals with pre-determined number of buttons, I have individual actions defined for each button and I am able to show their respective dynamic content. However to identify Level 2 button click actions, I am grouping them together with a common class name eg: "dynamicbuttons".
However I am unable to register the action to display any kind of content in div 3.
Here's my jQuery sample code:
$(document).ready(function() {
$('#button1A').on("click", function(event) {
$('#div2').html("<p> This is normal div 2</p><br><input type='button' id='button2' class='dynamicbuttons' value='Button 2'>");
$('#div2').show();
});
$('#button1B').on("click", function(event) {
$('#div2').html("<p> This is heavily populated div 2</p><br><input type='button' id='button2A' class='dynamicbuttons' value='Button 2A'><br><br><br><input type='button' id='button2B' class='dynamicbuttons' value='Button 2B'>");
$('#div2').show();
});
$('.dynamicbuttons').on("click", function(event) {
$('#div3').html("<p> This is div 3</p>");
$('#div3').show();
});
});
I have created a jsfiddle with my scenario here : https://jsfiddle.net/2waL6m51/
Can someone provide me any pointers on how to solve this problem?