Calling function by closing popup

Calling function by closing popup

Hello,

I make a popup in jQuerymobile with
  1. <div data-role="popup" id="pop_'.$row_artikel['ArtikelNr'].'" data-theme="a" data-overlay-theme="b" class="ui-content" style="max-width:340px; padding-bottom:2em;">
  2. <h3>Artikel in den Warenkorb legen?</h3>
  3. <p><strong>CD Player</strong></p>
  4. <p>Sie k&ouml;nnen den Artikel sp&auml;ter noch aus dem Warenkorb l&ouml;schen. Die Bestandspr&uuml;fung findet es im n&auml;chsten Schritt statt.</p>
  5. <a href="#" name="artikel_999" class="ui-shadow ui-btn ui-corner-all ui-btn-b ui-icon-check ui-btn-icon-left ui-btn-inline ui-mini">Entnehmen</a>
  6. <a href="#" data-rel="back" class="ui-shadow ui-btn ui-corner-all ui-btn-inline ui-mini">Abbrechen</a>
  7. </div>
Now, I want to call the following funktion when I close the popup:
  1. <script type="text/javascript">
  2. $(function(){
  3. $(document).on('click', 'a[name^="artikel_"]', function() {
  4. var id = this.name;
  5. alert(id);
  6. $.ajax({
  7. type: "POST",
  8. url: "work/artikel_in.php",
  9. data: {ID: id},
  10. success: function(msg){
  11. alert(msg);
  12. }
  13. });
  14. });
  15. });
  16. </script>
The names like "artikel_" are made by PHP MySQL Query.

I tested, when I call with onClick="test()" in the popup button, it works, but only a normal funktion like test(){alert('Hi')}, and only if it stands behind the popup div.

Why I couldn´t call the function? Without popup it works fine!
- When the link is in the main page, and not in the popup.

Sorry for my bad english. I hope you can help me!

Thank you!!!