Best way to build a select used in several places?


#1

I would like to have a select with a list of words in several places. What’s the best way to do that and be able to name each one with a unique name in the form? I guess an array but how and where to place it?


#2

The list will be static or will it be updated in between?


#3

blaze components
autoform have their own custom templates too


#4

The list will be static.


#5

I wasn’t thinking. I guess I can do a template with a regular select list. How do I add a dynamic name?


#6
<template name="universal">
  <div class={{customClass}}>
    Hello World
  </div>
</template>

{{> universal customClass="my-class-1"}}

#7

Perfect. Exactly what I need.


#8

but be carefull, cause by doing this, you are loosing data context which was initialy for that template
if you still want to use that data context, you need to pass it to template, for example like myData=this and then reference it using that myData.

for static lists it is easy

I am passing also inputArray=something and than iterating over array, so list does not have to be static etc…


#9

Meteor blaze components is pretty good for reusable components.


#10

I realize that I should probably learn Meteor blaze components but how do I mark an option as selected with an existing value in a select list using the template solution for the time being?