Has anyone had any success using a vertical table column as a view ‘el’ using Backbone.js? Since tables are row-based, using a table row as the DOM container associated with the view is trivial. However, the layout I’m required to implement is vertical, so a table column would be the ‘el’ of my design, but table columns don’t have a similar container element since table layout is horizontal.
So far, I haven’t been able to successfully create child views for the table columns, which means I’m tying data to my DOM in order to retrieve and manipulate table columns. My design has gotten much more complex, which is causing me to reevaluate the original approach in the hope that there is a better way to manage this scenario through child views. Any ideas?
You could take advantage of the fact that
this.$elin a view can then be whatever nodes you wantWith that in mind, you could render your table in one go (see BackboneJS Rendering Problems, it’s faster and in your case probably much easier) and then apply your subviews on the table cells associated with the model. I went with a class name for selection but a selector on the nth element of each row should work.
Template
View
As you can check in this demo http://jsfiddle.net/nikoshr/psasT/12/, each column is handled by a dedicated view.