Fix Javascript exception by adding invisible elements
authorNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Sun, 3 Nov 2013 17:00:07 +0000 (18:00 +0100)
committerNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Sun, 3 Nov 2013 17:20:12 +0000 (18:20 +0100)
_selectAll('to_contacts') and _selectAll('cc_contacts') were raising:
"TypeError: Cannot read property 'length' of null"
Add missing <select> elements until the code is rewritten to take care of this
situation.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
templates/emails/send.tpl

index 0a321b6..ab40ffd 100644 (file)
     </tr>
     {/if}
   </table>
+  {if $contacts|@count eq 0}
+    {* Current Javascript code needs some elements to exist. *}
+    {* TODO: rewrite the code to accept non-existent elements without raising exceptions *}
+    <select id="to_contacts" name="to_contacts[]" multiple="multiple" style="display: none;">
+      <option value="">&nbsp;</option>
+    </select>
+    <select id="cc_contacts" name="cc_contacts[]" multiple="multiple" style="display: none;">
+      <option value="">&nbsp;</option>
+    </select>
+    <select id="contacts" name="all_contacts[]" multiple="multiple" style="display: none;">
+      <option value="">&nbsp;</option>
+    </select>
+  {/if}
   <fieldset>
     <legend>Sujet&nbsp;:&nbsp;<input type='text' name='sujet' size='60' value="{$smarty.request.sujet}" /></legend>
     <div class="center">