wycats / handlebars-site

56 stars 66 forks source link

having issue with handlebars and sheetrock #148

Closed justawebbie closed 7 years ago

justawebbie commented 8 years ago

I am having an issue using handlebars with sheetrock.js. I am not sure what it can be because it was working then all of sudden stopped.

Here is my JS fiddle

Here is the code just in case you prefer that over a JS fiddle.

<table id="eap">
              <thead>
                     <tr>
                           <th>Date</th>
                            <th>Building</th>
                             <th>Department or school</th>
                              <th>Prepared by</th>
                              <th>Download EAP</th>
                              <th>Edit EAP</th>
                     </tr>
                </thead>
             <script id="eap-table" type="text/x-handlebars-template">
                      <tr>
                                <td>{{cells.Datemade}}</td>
                                <td>{{cells.Building}}</td>
                                <td>{{cells.Department}}</td>
                                <td>{{cells.Prepared}}</td>
                                <td><a href="{{cells.link1}}">Edit</a></td>
                           <td><a href="{{cells.link2}}">Download</a></td>
                       </tr>
                </script>
    </table> 
<script type="application/javascript">
                 var sySpreadsheet = 'https://docs.google.com/spreadsheets/d/1Ui4RtCkuggvg9HPB2G8sFcUuutzeE-JPoBapLnBZHok/edit#gid=0'; //Google sheet: EAP websites

             var EPTemplate = Handlebars.compile($('#eap-table').html());

              $('#eap').sheetrock({
                url: sySpreadsheet,
                query: "select A,C,D,E,F,G order by E asc",
                     rowTemplate: EPTemplate
                });

              </script>`
tjferry14 commented 7 years ago

I know this is old, and not sure why this is happening, but replacing {{cells.Datemade}} with {{cellsArray.[0]}} and so on for each cell seems to fix the problem. I would head over to the Sheetrock repo and raise an issue there if further problems arise.

justawebbie commented 7 years ago

Thank you TJ for the information.

I figured out how to get it to use my {{cells.Datemade}} by adding into the sheetrock parms: labels: [' Datemade', 'Building', 'Department', 'Prepared','link1',' link2'], and you have to have as many labels as you query or it will not work as well.

nknapp commented 7 years ago

Seems to be resolved.