Date Mon 04 April 2011 Tags cloud

If you wanted to make a select or checkbox element using mustache in couch db and trying to find example, here it is:

I am using couchdb so in shows, album-edit.js, I want a dropdown menu for group variable in couchdb.

var Mustache = require("vendor/couchapp/lib/mustache");  var label=[];    var selected=null;    for (i=1;i<=5;i++){       group_label="Level "+i;       selected=(i==doc.group);       label.push({label:group_label,value:i,selected:selected});                   }        ...               return Mustache.to_html(this.templates.albumedit, stash, this.templates.partials.albumedit);

In templates albumedit.html add

Group     {{%IMPLICIT-ITERATOR iterator=label}}    {{#labels}}        {{label}}   {{/labels}}

That's it. I was using tutorial as a basis for my CRUD with couchdb.


Comments

comments powered by Disqus