{/if}
<tr>
<td class="label">{$form.attachFile_1.label}</td>
- <td>{$form.attachFile_1.html} {$form.attachDesc_1.html}<a href="#" class="crm-hover-button" title="{ts}Clear{/ts}" onclick="clearAttachment( '#attachFile_1', '#attachDesc_1' ); return false;"><span class="icon close-icon"></span></a><br />
- <span class="description">{ts}Browse to the <strong>file</strong> you want to upload.{/ts}{if $maxAttachments GT 1} {ts 1=$maxAttachments}You can have a maximum of %1 attachment(s).{/ts}{/if} {ts 1=$config->maxFileSize}Each file must be less than %1M in size. You can also add a short description.{/ts}</span>
+ <td>{$form.attachFile_1.html} {$form.attachDesc_1.html}<a href="#" class="crm-hover-button crm-clear-attachment" style="visibility: hidden;" title="{ts}Clear{/ts}"><span class="icon close-icon"></span></a>
+ <div class="description">{ts}Browse to the <strong>file</strong> you want to upload.{/ts}{if $maxAttachments GT 1} {ts 1=$maxAttachments}You can have a maximum of %1 attachment(s).{/ts}{/if} {ts 1=$config->maxFileSize}Each file must be less than %1M in size. You can also add a short description.{/ts}</div>
</td>
</tr>
{if $form.tag_1.html}
<tr class="attachment-fieldset"><td colspan="2"></td></tr>
<tr>
<td class="label">{$form.attachFile_1.label}</td>
- <td>{$form.$attachName.html} {$form.$attachDesc.html}<a href="#" class="crm-hover-button" title="{ts}Clear{/ts}" onclick="clearAttachment( '#{$attachName}' ); return false;"><span class="icon close-icon"></span></a></td>
+ <td>{$form.$attachName.html} {$form.$attachDesc.html}<a href="#" class="crm-hover-button crm-clear-attachment" style="visibility: hidden;" title="{ts}Clear{/ts}"><span class="icon close-icon"></span></a></td>
</tr>
<tr>
<td class="label">{$form.$tagElement.label}</td>
</div><!-- /.crm-accordion-wrapper -->
{literal}
<script type="text/javascript">
- function clearAttachment( element, desc ) {
- cj(element).val('');
- cj(desc).val('');
- }
+ CRM.$(function($) {
+ var $form = $("#{/literal}{$form.formName}{literal}");
+ $form
+ .on('click', '.crm-clear-attachment', function(e) {
+ e.preventDefault();
+ $(this).css('visibility', 'hidden').closest('td').find(':input').val('');
+ })
+ .on('change', '#attachments :input', function() {
+ $(this).closest('td').find('.crm-clear-attachment').css('visibility', 'visible');
+ });
+ });
</script>
{/literal}
{/if} {* edit/add if*}