0

jQuerymobileを使用してモバイルアプリを構築しようとしています。現在の私の問題は次のとおりです。私のhtmlにはリストがあります(動的にロードされ、リストアイテムがどれだけ含まれているかわからないので、この例では3を取り上げます。tupelIDの値も不明です):

<ul id="bibliothek" data-role="listview" data-divider-theme="b" data-inset="true">
<li data-theme='c'><a class='bibentry' href='#page1' data-transition='slide' tupelID='1'> Item 1</a></li>
<li data-theme='c'><a class='bibentry' href='#page1' data-transition='slide' tupelID='2'> Item 2</a></li>
<li data-theme='c'><a class='bibentry' href='#page1' data-transition='slide' tupelID='3'> Item 3</a></li>
</ul>

ユーザーがこれらのリストアイテムの1つをクリックすると、新しいページが読み込まれます(#page1)。このページでは、a-tagからのパラメーター(tupelID)に基づいていくつかのデータを挿入したいと思います。最も簡単な方法は、リスト(jQuery('a.binetry'))からすべてのリンクをgrepし、それぞれにイベントリスナーを追加することだと思いました。

jQuery('a.bibentry').addEventListener("click",function(this)
{
    alert "TupelID =" + this.tupelID
    // first test with a simple alert:
    // If users clicks on Item 1 the alert should be "1" (value of tupelID),
    // if users clicks on Item 2 the alert should be "2" (value of tupelID) and so on..
});

残念ながら、これは機能せず、Webで問題の解決策を見つけることができませんでした。誰か助けてもらえますか?

4

2 に答える 2

1

これを試してください->

jQuery('a.bibentry').on("click",function()
    {
        alert("TupelID =" + $(this).attr('tupelID'));
        // first test with a simple alert:
        // If users clicks on Item 1 the alert should be "1" (value of tupelID),
        // if users clicks on Item 2 the alert should be "2" (value of tupelID) and so on..
    });
于 2012-04-27T09:27:43.810 に答える
0
$('#bibliothek').on('a.bibentry', 'click', function(){
  alert("TupelID =" + $(this).attr('tupelID'));
});
于 2012-04-27T09:30:14.963 に答える