I'm working with Google Material Design components which are stripped down for simplicity, then rendered more fully when the page is loaded. Simplified below to illustrate the issue:
What shows in the index.html file:
<div class="switch"></div>
What renders to the DOM when the page is loaded:
<div class="switch">
<div class="switch_track"></div>
<div class="switch_thumb"></div>
</div>
I am creating a drag and drop HTML editor and have template files for each component type. The template file for a switch is simply:
switch.html
<div class="switch"></div>
The problem is when I drag this to the canvas. jQuery looks at switch.html
and renders <div class="switch"></div>
to the DOM, but since it was dynamically added, it is not being "seen" by the scripts that added the additional track and thumb tags.
How can I fix this issue so that whenever the DOM is updated, it reruns any scripts? Ideally I would like to avoid touching any of the Material Design script files.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…