{{#each options}}

Passing reusable blaze dropdown to sweet alert 2 html

57 views Asked by At

I have a simple meteor template that creates a dropdown:

<template name="Select">
  <div class="input-fields">
    <select>
      {{#each options}}
        <option value="{{_id}}" selected={{optionSelected}}>{{name}}</option>
      {{/each}}
    </select>
  </div>
</template>

I normally use it by adding it as a blaze spacebar:

 {{> Select 
      options=options
    }}

Now I'm trying to pass this dropdown as the HTML argument inside a Sweet Alert 2 dialog, but blaze doesn't render the component, since swal is probably triggered after the blaze rendering is already finished. Is there another way to reuse the template inside the swal call?

swal.fire({
      title: "MyDropdown",
      HTML: "{{> Select 
                options="+options+"}}",
})

I know you can natively add a dropdown in Sweet Alert 2, but I'm specifically interested in how to add my own templates to it.

1

There are 1 answers

0
Oluwafemi Peters On

Did you try

Blaze.toHTML('Select') 

or

Blaze.toHTMLWithData('Select',{options})