[whatwg] Repetition Template Rendering Fix for Script-enabled Clients

Matthew Raymond mattraymond at earthlink.net
Mon Jun 28 04:54:59 PDT 2004


    I have yet to come up with a good way to keep the repetition 
template from rendering on script-enabled browsers. Here's a modified 
version of one of the examples from the Web Forms 2.0 draft:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
  <head>
   <title>Sample Order Form</title>
  </head>
  <body>
   <table>
    <tr>
     <th>Product</th>
     <th>Quantity</th>
    </tr>
    <script language="JavaScript" src="order_template.js"></script>
    <noscript>
     <tr id="order" repeat="template" repeat-start="3">
      <td><input type="text" name="row[order].product"></td>
      <td><input type="text" name="row[order].quantity" value="1"></td>
     </tr>
    </noscript>
   </table>
   <p><button type="add" template="order">Add Row</button></p>
   <p><button type="submit">Submit</button></p>
  </body>
</html>


    The file "order_template.js" would contain the following:

if(document.implementation && document.implementation.hasFeature &&
    document.implementation.hasFeature('WebForms', '2.0')) {
   document.write('<tr id="order" repeat="template" repeat-start="3">');
   document.write('<td>');
   document.write('<input type="text" name="row[order].product">');
   document.write('</td>');
   document.write('<td>');
   document.write('<input type="text" name="row[order].quantity" 
value="1">');
   document.write('</td>');
   document.write('</tr>');
}


    This would not change how the WF2 repetition model works with UAs 
that have disabled or non-existent scripting support, but it would 
prevent unwanted template blocks from showing up on script-enabled 
clients. I'll continue to work on a way to get the same effect without 
scripting.



More information about the whatwg mailing list