I have an ajax request that dynamically creates a modal window with radio buttons.
I see in the materialize documentation that you can execute material_select() to get selects , however, correctly, I do not see in the documentation on initializing radio dynamically.
How to initialize dynamically loaded switches?
For reference, here is an example of a modal that I load dynamically:
<div id="import-modal" class="modal modal-fixed-footer"> <div class="modal-content"> <h4>Import Data</h4> <p> <input name="import-group" type="radio" id="import-modal-csv"/> <label for="import-modal-csv">Csv</label> <div>Import a csv file.</div> <p/> <p> <input name="import-group" type="radio" id="import-modal-excel"/> <label for="import-modal-excel">Excel</label> <div>Import a excel file.</div> </p> </div> <div class="modal-footer"> <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">Import</a> </div> </div>
change 1
I add the dynamic div above using jquery to the parent container on the click button:
import_click: function(){ $.ajax({ url: 'template/import.html', success: function (response) { $('#container').append(response); } }); }
source share