title: Dynamic select with data-attribute doesn't work
body: <p>I have an empty <code>select</code> element with dynamically added <code>option</code> elements. The <code>option</code> elements have a <code>attribute</code> called <code>data-municipality</code>.</p>
  
  <p>I'm using this variable in a function, but it is as though the function just gets "undefined" instead of the actual variable value.</p>
  
  <p>Here's my function, that sets the variable and prints it to the console:</p>
  
  <pre><code>  $( "#fromMunicipality" ).change(function() {
      fromMunicipalityCode = $("#fromMunicipality option:selected").data("municipality");
      console.log(fromMunicipalityCode);
    });
  </code></pre>
  
  <p>And here's the function I'm using the variable <code>fromMunicipalityCode</code> in:</p>
  
  <pre><code>$('#fromAddress').dawaautocomplete({
    adgangsadresserOnly: true,
    params: {
      kommunekode: fromMunicipalityCode
    },
    select: function(event, adresse) {
    }
  });
  </code></pre>
  
  <p>When I run the function above, <code>fromMunicipality</code> is undefined, even though the attribute changes in the console, or at least it doesn't use the value in the function.</p>
  
  <p>What could be the issue here?</p>
  
  <p>Thanks!</p>