I have a template like
script type: "text/template", id: "list-template", ''''''
<input class="list-input" type="text" value="" /> <input id="hdnListId" type="hidden" value="" />
in this template i have
element in which i want to render another template which display list inside this ul. this template is :
script type: "text/template", id: "card-template", ''''''
is it possible or i have to do it in another way? please help me if anyone have idea. thanks in advace.
it is worked but still i have one problem in data display in
- as per records in my database but it will display only 1
. data fetch properly but display only last data.
Problem courtesy of: priyanka patel
there sholud be 2
There are two ways to do this: the DOM way and the template way.
The DOM way involves adding your views using DOM methods: you have your ListView and your CardView; the ListView invokes individual CardViews that fill in the ListView’s element.
The template way requires that you remember this: backbone’s views are policy frameworks, not policy templates. Render doesn’t have to render into the DOM
. You can use
to return a string, for example. If your event manager is on the ListView object only (possible; I’ve done this), then you can have ListView invoke “the resulting array of an array of CardView renders” and insert that directly into ListView’s template. This is actually faster, as you only require the browser to analyze the entire ListView HTML blob once, when it’s inserted into the innerHTML of the parent DOM object.
Solution courtesy of: Elf Sternberg