问题
I'm trying to add the html5 drag 'n drop upload file on my JSF web page so i had to add this script into it
<script type="text/html" id="template-uploads">
//<![CDATA[
<div data-bind="visible: showTotalProgress()">
<div>
<span data-bind="text: uploadSpeedFormatted()"></span>
<span data-bind="text: timeRemainingFormatted()" style="float: right;"></span>
</div>
<div class="uploadimage-totalprogress">
<div class="uploadimage-totalprogressbar" style="width: 0%;" data-bind="style: { width: totalProgress() + '%' }"></div>
</div>
</div>
<div data-bind="foreach: uploads">
<div class="uploadimage-upload" data-bind="css: { 'uploadimage-uploadcompleted': uploadCompleted() }">
<div class="uploadimage-fileinfo">
<strong data-bind="text: fileName"></strong>
<span data-bind="text: fileSizeFormated"></span>
<span class="uploadimage-progresspct" data-bind="visible: uploadProgress() < 100"><span data-bind="text: uploadSpeedFormatted()"></span></span>
</div>
<div class="uploadimage-progress">
<div class="uploadimage-progressbar" style="width: 0%;" data-bind="style: { width: uploadProgress() + '%' }"></div>
</div>
</div>
</div>
//]]>
</script>
if i take out the cdata tag which is around my script i get this error :
The value of attribute "data-bind" associated with an element type "span" must not contain the '<' character.
回答1:
The script you've posted is a text/html script which acts as a template in knockout. That id is required for knockout to reference the template.
As for the CDATA sections, unless you're using XML you can take them out.
来源:https://stackoverflow.com/questions/19860518/appears-on-the-page-when-cdata-are-us