Calling function by closing popup
Hello,
I make a popup in jQuerymobile with
- <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;">
- <h3>Artikel in den Warenkorb legen?</h3>
- <p><strong>CD Player</strong></p>
- <p>Sie können den Artikel später noch aus dem Warenkorb löschen. Die Bestandsprüfung findet es im nächsten Schritt statt.</p>
- <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>
- <a href="#" data-rel="back" class="ui-shadow ui-btn ui-corner-all ui-btn-inline ui-mini">Abbrechen</a>
- </div>
Now, I want to call the following funktion when I close the popup:
- <script type="text/javascript">
- $(function(){
- $(document).on('click', 'a[name^="artikel_"]', function() {
- var id = this.name;
- alert(id);
- $.ajax({
- type: "POST",
- url: "work/artikel_in.php",
- data: {ID: id},
- success: function(msg){
- alert(msg);
- }
- });
- });
- });
- </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!!!