これが私のコードの基本的な考え方です。実際のコードから多くの余分なものを削除しましたが、ほとんどは css でした - どれもこれに影響を与えるべきではありません...
listRef.on('child_removed', function(childSnapshot, prevChildName) {
alert('child removed!');
});
listRef.on('child_added', function(childSnapshot, prevChildName) {
itemRef = childSnapshot.ref();
alert('child added!);
itemRef.on('value', function(snapshot){
alert('item value changed!');
var name = snapshot.val().name; // if I remove this line, child_removed is called
$("#name").html(name);
});
});
$("#button").click(function() {
itemRef.remove();
});
問題は、$("#button")
クリックすると、itemRef が Firebase の listRef から削除されることですが、'child_removed'
イベントがトリガーされることはありません...
driveRef = undefined;
それからchild_removed
呼ばれます...
他のすべてが機能します-$("#name")
更新され、alert()
テストに使用しているすべてのダイアログが正常に機能しています-唯一の問題はchild_removed
呼び出されていません。