jessiPP
jessiPP

Reputation: 446

selectize does not work in meteor

Can any one tell me why this work in meteor:

"landTenancyType" : {
  type: String, 
  optional: true,
  autoform: {
    type: "selectize",
    options: function(){

     return [
      {label: "Joint", value: "Joint"},
      {label: "Tenancy In Common", value: "Tenancy In Common"}
     ]
  }
 }
}

but this does not work:

"landTenancyType" : {
  type: String, 
  optional: true,
  autoform: {
    type: "selectize",
    options: function(){
       return Categories.find().map(function(obj) {
         console.log(obj);
         return { label: obj.name, value: obj.name };
      });

  }
}
}

All the necessary publish and subscribe are working. Console does also show that values are coming from the collection. However a blank selectize ui is killing me. If i change type: "selectize", to type: "select", the select list is populated but i do not have the selectize goodness i need. Any ideas what I am doing wrong?

By the way I am using meteor with autoform 5.0 and comerc:autoform-selectize.

Upvotes: 0

Views: 251

Answers (2)

Raiyan
Raiyan

Reputation: 1687

I think the problem is in this line:

Categories.find().map(function(obj)

find returns a cursor, you could do find().fetch() to get an array. Then map would work on that array.

Upvotes: 1

ashish1dev
ashish1dev

Reputation: 81

Can you return object wittin another objects from a function ? A function will always return a single entity (either single value or single object). Please re-check your code's following section:

options: function(){
   return Categories.find().map(function(obj) {
     console.log(obj);
     return { label: obj.name, value: obj.name };
   });
}

Upvotes: 0

Related Questions