backbone.js - Backbone repeated templates with different types -
i trying figure out best way structure following using backbone views , templates. have collection of "messages", messages may of different types, each it's own view. so, underlying collection might like:
{ { id: 1, name="message one", type="customer-message" }, { id: 2, name="message two", type="support-message" }, { id: 3, name="attachment one", type="attachment" } }
and resulting page output like:
<ul> <li class="message customer-message"></li> <li class="message support-message"></li> <li class="message attachment"></li> </ul>
such each different li class have entirely different structure/content.
what i'm trying figure out how set templates , views a) handle nesting , b) handle fact inner template differs depending on type.
<script type="text/template" id="chat-template"> <ul> <!--how reference other templates here?--> </ul> </script> <script type="text/template" id="customer-message-template"> </script> <script type="text/template" id="support-message-template"> </script> <script type="text/template" id="attachment-template"> </script>
not looking full solution here - hoping there's example can point me to.
thanks!
take @ backbone.marionette provides view "subclasses" handling collection scenarios this. http://marionettejs.com/
Comments
Post a Comment