title: jquery - unable to fire click event for second time on the same element
body: <p>I have a jquery mobile page with click event attached to a series of elements with a class selector. When i click the first element ,everything is fine but  if i change page and come back , the click event fires but fails to traverse the DOM. Here is the simplified version.</p>
  
  <pre><code>&lt;div class="someSelector"&gt;&lt;/div&gt;
  &lt;div class="someSelector"&gt;&lt;/div&gt;
  &lt;script&gt;
    $(function(){
      $(body).on('click','.someSelector',function(){
        alert('Hello World') // This works everytime
        alert($(this).parent().attr('id')) // This returns 'undefined' for the second time
      })
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>So, the problem is, i am unable to traverse the DOM using click event ,by clicking on the same element for the second time, after returning from another page .
   If i do not navigate to another page , this problem doesn't occur. 
  Here is the relevant part of the page which is inserted into the <code>div[data-role="content"]</code></p>
  
  <pre><code>{% for item in user_posts.object_list %}
     {% if item.share_with != 'share with none' %}
         {% if  item.type != 'status_update' %}
             &lt;div class="post" id="post-{{ item.id }}"&gt;
                &lt;div class="postInfoWrapper"&gt;
                    {% if item.posted_by.get_profile.get_profile_picture %}
                    &lt;img class="user_photo" src="{{ item.posted_by.get_profile.get_profile_picture }}" height="50" width="50" /&gt;
                    {% else %}
                    &lt;img class="user_photo" src="{{ STATIC_URL }}images/default_profile_picture.png" height="50" width="50"/&gt;
                    {% endif %}
                    &lt;div class="postInfo"&gt;
                        &lt;p class="title"&gt;{{ item.title|striptags|capfirst }}&lt;/p&gt;
                        &lt;p class="publisher_info"&gt;Posted by &lt;a class="user" href="/{{ item.posted_by.username }}/"&gt;Dr.{{ item.posted_by.get_full_name|capfirst }}&lt;/a&gt; to
                        &lt;span&gt;
                            {% for speciality in item.relevance.all %}
                                {{ speciality.name }},
                            {% endfor %}
                        &lt;/span&gt;
                        &lt;/p&gt;
                        &lt;span class="dated"&gt;{{ item.date_posted|addDate:user|naturalday:user }} at {{ item.date_posted|addDate:user|date:"h:i a" }}&lt;/span&gt;
                        &lt;a href="#postOptions" id="options" data-rel="popup" data-position-to="window" data-transition="flip" class="ui-alt-icon ui-nodisc-icon ui-btn ui-corner-all ui-icon-carat-d ui-btn-icon-notext ui-btn-inline"&gt;Delete&lt;/a&gt;
                        &lt;div data-role="popup" id="postOptions" data-theme="b"&gt;
                            &lt;ul data-role="listview"&gt;
                                &lt;li data-icon="edit"&gt;&lt;a href="#"&gt;Edit&lt;/a&gt;&lt;/li&gt;
                                &lt;li data-icon="delete"&gt;&lt;a href="#"&gt;Delete&lt;/a&gt;&lt;/li&gt;
                                &lt;li data-icon="action"&gt;&lt;a href="#"&gt;Move to drafts&lt;/a&gt;&lt;/li&gt;
                            &lt;/ul&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="subject"&gt;
                   &lt;div class="subject_full"&gt;
                   {% autoescape off %}
                   {{ item.subject|urlize }}
                   {% endautoescape %}
                   &lt;/div&gt;
                &lt;/div&gt;
         &lt;/div&gt;
         {% else %}
  
          &lt;div class="post" id="status_post_{{ item.id }}"&gt;
              &lt;div class="imageGroup" style="display: none;"&gt;
              &lt;div id='slider_qp_{{ item.id }}' class='swipe' data-role="none"&gt;
                      &lt;div class='swipe-wrap'&gt;
                          {% if item.image %}
                          &lt;div&gt;
                              &lt;img src="{{ item.image.url }}" width="{{ item.get_image_width  }}" height="{{ item.get_image_height }}"
                                    class="quick-post-image"/&gt;
                          &lt;/div&gt;
                          {% endif %}
                          {% if item.image_2 %}
                          &lt;div&gt;
                              &lt;img src="{{ item.image_2.url }}" width="{{ item.get_image_2_width  }}" height="{{ item.get_image_2_height }}"
                                    class="quick-post-image"/&gt;
                          &lt;/div&gt;
                          {% endif %}
                      &lt;/div&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="post_capsule"&gt;
                  &lt;div class="postInfoWrapper"&gt;
                      {% if item.posted_by.get_profile.get_profile_picture %}
                      &lt;img class="user_photo" src="{{ item.posted_by.get_profile.get_profile_picture }}" height="50" width="50" alt=""/&gt;
                      {% else %}
                      &lt;img class="user_photo" src="{{ STATIC_URL }}images/default_profile_picture.png" height="50" width="50" alt=""/&gt;
                      {% endif %}
                          &lt;div class="postInfo"&gt;
                              &lt;p class="publisher_info"&gt;
                                  &lt;a class="user" href="/{{ item.posted_by.username }}/"&gt;Dr {{ item.posted_by.get_full_name|capfirst }}&lt;/a&gt;
                              &lt;/p&gt;
                              &lt;span class="dated"&gt;{{ item.date_posted|addDate:user|naturalday:user }} at {{ item.date_posted|addDate:user|date:"h:i a" }}&lt;/span&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                          &lt;div class="subject_full"&gt;
                              &lt;p&gt;{{ item.status_update|striptags|urlize }}&lt;/p&gt;
                                  {% if item.image %}
                              &lt;img src="{{ item.image.url }}" width="{{ item.image.width  }}" height="{{ item.image.height }}"
                                   style="cursor: pointer;border: 1px solid #aaa;margin-bottom: 5px;" class="quick-post-image"/&gt;
                              {% endif %}
                              {% if item.image_2 %}
                              &lt;img src="{{ item.image_2.url }}" width="{{ item.image_2.width  }}" height="{{ item.image_2.height }}"
                                   style="cursor: pointer;border: 1px solid #aaa;" class="quick-post-image"/&gt;
                              {% endif %}
                          &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
         {% endif %}
     {% endif %}{% endfor %}
  </code></pre>
  
  <p>Th script:</p>
  
  <pre><code>$(function(){
              $(document).on('click','.quick-post-image',function(e){
                  var that = $(this);
                  var elem = that.parents('.post').find('.swipe').attr('id');
                  $('#swipeContainer').html($('#'+elem));
                  $(':mobile-pagecontainer').pagecontainer('change','#imagePopup');
                  $('#imagePopup').trigger('create');
              });
          });
  </code></pre>