Car*_*ñoz 22 javascript ajax script-tag jquery-templates
我有这个模板,其中包含来自youtube的视频,其中包含swfobject.
有没有办法包含脚本标签......
<script type="text/javascript">
</script>
Run Code Online (Sandbox Code Playgroud)
在jQuery模板里面?
<script id="filaVideoTemplate" type="text/x-jQuery-tmpl">
<!-- Some HTML here -->
<script type="text/javascript">
<!-- Some javascript here -->
</script>
</script>
Run Code Online (Sandbox Code Playgroud)
显然它不能直接工作,有没有办法在没有其他脚本内的脚本的情况下实现同样的事情?
小智 24
<script id="filaVideoTemplate" type="text/x-jQuery-tmpl">
<!-- Some HTML here -->
<script type="text/javascript">
<!-- Some javascript here -->
{{html "</sc"+"ript>"}}
</script>
Run Code Online (Sandbox Code Playgroud)
您可以使用{{html"</ sc"+"ript>"}}替换</ script>
不确定这是否是唯一的方法,但您可以将脚本作为模板的原始 HTML 插入:
<script id="filaVideoTemplate" type="text/x-jQuery-tmpl">
<!-- Some HTML here -->
{{html innerScript}}
</script>
Run Code Online (Sandbox Code Playgroud)
然后:
var innerScript = '<script type="text/javascript"><!-- Some javascript here --></script>';
$('#filaVideoTemplate').tmpl({innerScript: innerScript});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18353 次 |
| 最近记录: |