theironcook / Backbone.ModelBinder

Simple, flexible and powerful Model-View binding for Backbone.
1.42k stars 159 forks source link

CollectionBinder: How to insert elements before/after a given element? #212

Closed ColinNiu closed 9 years ago

ColinNiu commented 9 years ago

Case: I have a table with the last row contains summary info. How can I insert elements before it? Currently all the items are appended to the table, the summary row turns to be the first row.

<table>
 <thead>
  <tr> <td> name </td> <td> price </td> </tr>
 </thead>
 <tbody>  
<!-- Here should be the repeated items -->
  <tr> <td> Total:</td> <td> {{sum}}  </td>  </tr>
</tbody>
</table>
rogerroelofs commented 9 years ago

Colin,

A better structure for what you are describing would be to put your total row inside a tfoot element. If that's not possible, there are other workarounds but using a good html element structure is your best bet.

On Wed, Apr 1, 2015 at 2:34 AM, Colin notifications@github.com wrote:

Case: I have a table with the last row contains summary info. How can I insert elements before it? Currently all the items are appended to the table, the summary row turns to be the first row.

name price
Total: {{sum}}

— Reply to this email directly or view it on GitHub https://github.com/theironcook/Backbone.ModelBinder/issues/212.

Roger

Roger Roelofs Know what you value.

ColinNiu commented 9 years ago

@rogerroelofs Thanks for you suggestion! tfoot solved my problem. I think inserting children items after/before a speicial element should be a rare case. For table, there are thead and tfoot; for other cases, fine structured div/span can be the solution.

platinumazure commented 9 years ago

@ColinNiu Sounds great! Would you like to close this issue, then?