javascript - Backbone.js Get First Element from JSON file -
while figured out how of elements array, stuck on trying element belonging first. using backbone.js , trying edit 1 of templates. track information getting coming json file. can within html file or must edit .js file?
html:
<script type="text/template" id="lesson-template"> <span class="lesson-title"><%= title %></span> <select class="sel"> <% _.each(tracks, function(track) { %> //this lets me loop through each of them <option value = "<%= track.text %>" ><%= track.title %></option> <% }); %> </select> //now want figure out way track.text of first track here , put in tracktext! <p id="tracktext">hello world!</p> </script>
<p id="tracktext"><%= tracks[0].text %></p>
you don't appear using backbone collections or models here. question javascript , underscore templates perhaps?
Comments
Post a Comment