title: Select2 - Get data from a loop
body: <p>I have a form-table and each row contains one select2, I want to get data from each of these and store it to array. Below is my code I would use, not sure if its proper attempt.</p>
  
  <pre><code>// event on each form change re-get the values
           $("#main").bind("keyup change", function (e) {
  
  
                          $('#form &gt; tbody  &gt; tr').each(function (i) {
  
          // get the data for each select
          // add it to array and use after loop for some logic
          // not sure if need this event here : select2:select
          // also the selector might be not in the node of current tr?
  
                              $('.selector').on("select2:select", function (e) {
  
                                  var data = $(this).select2('data');
  
                                 // push to array ?? data[0].custom_data
  
                              });
  
                          });
  
      // logic from array would be here
  
                      });
  </code></pre>