javascript - How to add pop-up window/modal to dynamically created tables -
html
<div class="wrapper"> <div class="profile"> <div id='entrydata'></div> </div> </div>
javascript
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script> $(function() { var dmjson = "data.json"; $.getjson(dmjson, function(data) { $.each(data.records, function(i, f) { var $table = "<table border=5><tbody><tr>" + "<td>" + f.clue + "</td></tr>" + "<tr><td>" + f.answer + "</td></tr>" + "<tr><td>" + f.status + "</td></tr>" + "<tr><td> " + f.views + "</td></tr>" + "</tbody> </table>" $("#entrydata").append($table) }); }); }); </script>
the above code creates tables dynamically , displays data json file. want make tables buttons , add pop windows these tables, such when table clicked pop-up appears , each pop should have different data. solution helpful. in advance.
the main trick going binding click handler document:
$(document).on("click", ".buttonintd", function() { /* give buttons 'buttonintd' class , add onclick code here */ });
doing allow dynamically create table , still capture events.
to handle modals , popups recommend grabbing 1 of multitude of plugins available that. featherlight
Comments
Post a Comment