Changing select label color


I have the following select

    {{#each orders_db}}
         <select class="bootstrapselect orderstatus">
          <option data-content="<span class='label label-info'>{{status}}</span>">{{status}}</option>
                      <option disabled>--------</option>
  <option data-content="<span class='label label-primary'>Awaiting</span>">Awaiting</option>
  <option data-content="<span class='label label-info'>Taken</span>">Taken</option>
  <option data-content="<span class='label label-success'>Delivered</span>">Delivered</option>
  <option data-content="<span class='label label-warning'>Shipped</span>">Shipped</option>
  <option data-content="<span class='label label-danger'>Cancelled</span>">Cancelled</option>

in JS

"change .orderstatus": function(event, template){
console.log($( ).val());'updateOrder', this._id, $( ).val());

orders_db: function(){
return Orders.find({}, {sort: {createdAt: -1}});

How do I change the depending on the status’ value?
eg. Shipped should have label-warning, cancelled should have label-danger and so on.

Use a helper to return the correct label string:

<option data-content="<span class='label {{labelType}}'>Shipped</span>">Shipped</option>
  labelType() {
    // some code here to return a string with the right value

As a test example works flawlessly, but I wonder what the logic behind this could should be.
I have a collection, each and every element is bound to have a “status”.

to get the collection displayed I use


orders_db: function(){
return Orders.find({}, {sort: {createdAt: -1}, limit: 20});


However how using

 labelType() {

I can now, compare status value and assign a string variable?

Yes - be aware that helpers will only run when they are first called, or if they have a reactive dependency. So you will most likely need to make this reactive. I assume the label type is based on a field or fields in the current document (as returned using your orders_db helper)? You may find that a cleaner approach is to use a transform in your new Mongo.Collection options to set up a “computed field” having the correct label type as part of the order document. Then you can refer to that in your template without an additional helper, which makes it really easy.