Can anyone tell me why this else if statement is not working? I have displayed both on the page to check their values after being processed, and they are indeed the same. However, it doesn’t work and I’m guessing it must be something with how I am comparing it. My code is below:
<script id="template-download" type="text/x-tmpl">
function test(arg){
output = arg;
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade">
{% if (file.error) { %}
<td></td>
<td class="name"><span>{%=file.name%}</span></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
// This is where I am having problems. I specify index zero and sooner or
// later file.name should match, but it never does and I'm not sure why??
// So then I do else if ( "5.jpg" == file.name ) and it does work....As you can
// see that I test it in the line right below the else if, and displays the same as file.name.
{% } else if ( output[0] == file.name ) { %}
<td class="name">{%=String(output[0])%}{%=String(file.name)%}</td>
<td class="preview">{% if (file.thumbnail_url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
{% } %}</td>
<td class="name">
<a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
</td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td colspan="2"></td>
{% } %}
<td class="delete">
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<i class="icon-trash icon-white"></i>
<span>{%=locale.fileupload.destroy%}</span>
</button>
<input type="checkbox" name="delete" value="1">
</td>
</tr>
}
{% } %}
}
</script>
Any ideas? Thanks in advance!!!