JAWS を使用してアクセシビリティの実装のいくつかをテストしていて、テーブルの 1 つで、aria-relevant=additions
.
関連するマークアップは次のとおりです。
<table role=log aria-live=polite aria-relevant=additions>
<thead>
<tr>
<th scope=col>Name</th>
<th scope=col>Time</th>
<th scope=col>Comment</th>
</tr>
</thead>
<tbody id=eventComments></tbody>
</table>
これで、テーブルを更新するコードは、すべてのコメントをプルして に挿入する AJAX リクエストを介して実行されますtbody
。
window.setInterval(function() {
$.ajax({
type: 'GET',
url: 'event.php',
data: {
eventID: ...
page: 'getComments'
},
dataType: 'html',
success: function(data) {
$('#eventComments').html(data);
}
});
}, 10000);
したがって、最初のコメントは次のように返されます。
<tr><th scope=row>Richard</th><td>2014-01-11 01:01:00</td><td>Security check in</td></tr>
2 つのコメントがある場合、データは次のようになります。
<tr><th scope=row>Justin</th><td>2014-01-11 01:18:31</td><td>Equipment failure</td></tr>
<tr><th scope=row>Richard</th><td>2014-01-11 01:01:00</td><td>Security check in</td></tr>
更新が発生するたびに、テーブル全体が読み取られますが、新しく追加された行を読み取るだけです。実際、新しい行が追加されていない場合でも、テーブル全体が 10 秒ごとに読み取られます。.prepend()
を使用して行を先頭に追加する可能性があることは知っていますが、サーバーから新しい行だけを取得することは現実的ではありません。
サーバーからすべての行を取得し、スクリーン リーダーに新しい行のみを読み取るように指示する方法はありますか?