title: Is there an alternative for onload on <select>?
body: <p>I am using jinja templates to compile a form of multiple select blocks based on a template variable dictionary, like this:</p>
  
  <pre><code>{% for key, value in some_template_variable_dict.items %}
          &lt;select id="{{ key }}_selector" name="key"&gt;
              {% for item in values %}
                  &lt;option value="{{ item }}"&gt;{{ item }}&lt;/option&gt;
              {% endfor %}
          &lt;/select&gt;
  {% endfor %}
  </code></pre>
  
  <p>I would like to fire the following wrapper function for selectize on all of the select blocks on loading the document:</p>
  
  <pre><code>function selectizeSingleChoice(selector) {
      $('#'+selector).selectize({
          sortField: 'text',
          maxItems: 1,
          create: false,
          highlight: true,
          openOnFocus: true
      });
  }
  </code></pre>
  
  <p>The select block does not have an onload event handler, and I cannot put it in a general $(document).ready(); section either, as the exact list of select blocks and their id-s is dependent on user choice. There is also an option that a slightly different version of the selectize wrapper is needed for some of them (e.g. not only one selected option allowed etc), so I cannot fire it on each and every select item either. </p>
  
  <p>A working solution is to insert a script tag inside the for loop, but I dislike it for being messy.</p>