I have the following schema { ... 'tags': { type: Array optional: true }, 'tags.$': { type: Object }, tags.$.tag': { type: String max: 10 } }
For my insert form, I want a helper that counts the number of tags currently created. Something like this: Template.my_template.helpers({ 'number_of_tags': function() { ... Need help with code here. } });
so that I can use the following in my template
`{{ number_of_tags }}
I tried the following but it always returns zero: Template.my_template.helpers({ 'number_of_tags': function() { return $("input[name^='tags']").length } });
I had noticed that all of the input fields took the following form ‘tags.#.tag’ so I thought I could just count them, but apparently not.