javascript - How to create mutliple spans from within a Backbone view -
i have a collection of model data need render inside div this:
_.each(model.stages, function(stagesdata){ this.$('.stagedate').text(stagesdata.get('status')); this.$('.stagestatus').text(stagesdata.get('timestamp')); });
this html
i'm trying render data:
<span class="stagedate"></span> <span class="stagestatus"></span>
now what's happening right shows last item inside model in view , not all. know because loop overwrites created span, wanted understand way go it? please suggest!
instead of text()
:
this.$('.stagedate').text(stagesdata.get('status'));
use append()
:
this.$('.stagedate').append('</p>' + stagesdata.get('status') + '</p>');
Comments
Post a Comment