solved: bind to taphold: "this" does not reference as expected
Hi
I have a listview where every li-element has an href with an id:
- $.getJSON("Projektliste.php?callback=?", function(data) {
- $.each(data, function(key, value) {
- $("<li><a href='Projekt.html?id=" + value.id +"' rel='external' id=" + value.id + ">" + value.PrName + "</a><span class='ui-li-count'>" + value.AnzBeob + "</span></li>").appendTo("#Projektlisteneintraege");
- });
- $("#Projektlisteneintraege").listview("refresh");
- });
I try to open a menu when the user tapholds a list-item:
- $('div').bind('taphold', function(event){
- var PrId = $(this).attr('id');
- alert("Die ID lautet: " + PrId);
- $.mobile.changePage("Projektliste_menu.html?id=" + PrId);
- });
I want to pass an id of the list-item that was tapheld. With this, it is possible to alter or delete list-items (and their data) in the menu.
The problem is: although every list-item has "id=" with a value, $(this).attr('id') does not fetch it.
This puzzles me, because I know that every list-item has a value in the id. And on another page I use the .change event which uses $(this).attr('id') too and that works perfectly:
- $("input").change(function() {
- var Feldname = $(this).attr("id");
Help is very much appreciated!