私は、ゲームが電話でどのように動作するかのように動作する通知システムを作成しています。これらのジェネリッククラスは、異なるdiv間でどのように区別できますか?
通知はすべて最初に作成され、隠され、後でゲームはゲーム内のトリガーから特定のものを「アクティブにする」と考えられます。
通知をクラスごとに分けて保存しようとすると、問題が発生しています。各通知は、タイトルのみが表示された小さな四角いボックスとして開始されます。クリックすると、通知が展開され、説明が表示されます。
今、通知をクリックするとその通知が展開され、通知が表示されますが、その他の通知にもその説明が表示されます。
例コード:
var NotificationItems = new Array();
scope.registerNotification = function(title, description)
{
//add it to the array
NotificationItems.push(new scope.Application(title, description));
var $NotificationContainer = $("#NotificationContainer");
$NotificationContainer.append('<div class="Notification" title="'+title+'"></div>');
var $thisNotification = $NotificationContainer.children('.Notification[title='+title+']');
$thisNotification.append('<div class="NotificationTitle">'+title+'</div>');
$thisNotification.append('<div class="NotificationDescription">'+description+'</div>');
$(".NotificationDescription").hide();
$thisNotification.click(function()
{
$(this).toggleClass('expanded');
$('.NotificationDescription').slideToggle('slow');
});
}
にはどうすれば.NotificationDescription
が一意に各通知のために認識されるように得ることができますか?
title属性に基づいて単一の通知オブジェクトを読み込むときは、実際にはすでにこの手法を使用しています。私はちょうどそれに気づいた! – TLS
ちょうど私が何をしているのか分かりません。どうもありがとう! – Briz