title: Find which box was clicked (or enter keypress)
body: <p>I have 4 containers and I need to know which one was clicked on, or when they press the "enter" key when focused on the input box.</p>
  
  <p>How can I modify my code to be able to do that?</p>
  
  <p><strong><a href="http://jsfiddle.net/Draven/qjs7c86v/" rel="nofollow">JSFiddle</a></strong></p>
  
  <p>HTML (only showing 2 of the containers here):</p>
  
  <pre><code>&lt;div id="boxes"&gt;
      &lt;div class="container e_type1" data-custom-data="e_type1"&gt;
          &lt;div class="header"&gt;&lt;h2&gt;E Type 1&lt;/h2&gt;&lt;/div&gt;
          &lt;div class="image"&gt;&lt;/div&gt;
          &lt;div class="footer"&gt;
              &lt;input type="text" name="item_level" value="1" class="item_level" min="1" step="1" required&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="container e_type2" data-custom-data="e_type2"&gt;
          &lt;div class="header"&gt;&lt;h2&gt;E Type 2&lt;/h2&gt;&lt;/div&gt;
          &lt;div class="image"&gt;&lt;/div&gt;
          &lt;div class="footer"&gt;
              &lt;input type="text" name="item_level" value="1" class="item_level" min="1" step="1" required&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="dialog" title="Progress"&gt;
      &lt;p&gt;
          &lt;div id="progressbar"&gt;
              &lt;div class="progress-label"&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/p&gt;
      &lt;div id="message"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS Snippet (full code can be found in the JSFiddle)</p>
  
  <pre><code>// Image container was clicked.
  //  Get data and send first Ajax request.
  $(".image").click(function () {
      //console.log("Let's Start! Image container was clicked");
      $("#dialog").dialog("open");
      var e_type_var = $(".container").data("custom-data"),
          item_level_var = $(this).$("#item_level").val();
          alert(e_type_var + " was clicked");
      forgeAjax(e_type_var, item_level_var, 'first_req', function (error) {
          // By default, show Cancel button.
          $("#dialog").dialog({
              buttons: [{
                  text: "Close",
                  click: function () {
                      $(this).dialog("close");
                  }
              }]
          });
          // Focus Cancel button
          $('.ui-dialog button:eq(1)').focus();
          // If there's no error returned, show Cancel and Button2 buttons.
          if (!error) {
              $("#dialog").dialog({
                  buttons: {
                      'Cancel': function () {
                          $(this).dialog('close');
                      },
                          'Button2': function () {
                          $("#message").html("");
                          startProgressBar(e_type_var, item_level_var);
                      }
                  }
              });
              // Focus Button2.
              $('.ui-dialog button:eq(2)').focus();
          }
      });
  });
  </code></pre>
  
  <p><strong>EDIT:</strong> Thank you everyone for pointing out the <code>id="item_level"</code>. It was an oversight on my part, does not explain why the code does not work though. And it has been removed from the question.</p>