title: Uncaught TypeError: Cannot read property 'options' of undefined javascript
body: <p>Everything works fine but from time to time there is a problem with the function. This makes it impossible to click a button and select a value from list. I tried to debug it but nothing is returned in the console.</p>
  
  <pre><code>_getSimpleProductId: function (element) {
          var allOptions = element.config.options,
              value = element.value,
              config;
  
          config = _.filter(allOptions, function (option) {
              return option.id === value;
          });
          config = _.first(config);
  
          return _.isEmpty(config) ?
              undefined :
              _.first(config.allowedProducts);
  
      }
  </code></pre>
  
  <p>Error occurs:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'options' of undefined</p>
  </blockquote>
  
  <p>I think I have to change my question to "What I'm doing wrong?".</p>