My user interaction process is as follows:
- The user is presented with a drop-down list containing a list of cities
- After selecting a city, an AJAX request gets all buildings in the city, and inserts them into a div (this AJAX request returns a list of checkboxes)
- The user then can check/uncheck a checkbox to add the city to a table that is on the same page. (This dynamically inserts/removes table rows)
Here is my select dropdown:
<label for="city-selector">Choose your favorite city?</label>
<select name="select" size="1" id="city-selector" aria-controls="city-info">
<option value="1">Amsterdam</option>
<option value="2">Buenos Aires</option>
<option value="3">Delhi</option>
<option value="4">Hong Kong</option>
<option value="5">London</option>
<option value="6">Los Angeles</option>
<option value="7">Moscow</option>
<option value="8">Mumbai</option>
<option value="9">New York</option>
<option value="10">Sao Paulo</option>
<option value="11">Tokyo</option>
</select>
Here is the ajax div that gets empties/populated:
<div role="region" id="city-info" aria-live="polite">
<!-- AJAX CONTENT LOADED HERE -->
</div>
Here is the checkbox list that gets placed inside the ajax div:
<fieldset id="building-selector" aria-controls="building-table">
<legend>Select your favorite building:</legend>
<input id="fox-plaza" type="checkbox" name="buildings" value="fox-plaza">
<label for="fox-plaza">Fox Plaza</label><br>
<input id="chrysler-building" type="checkbox" name="buildings" value="chrysler-building">
<label for="chrysler-building">Chrysler Building</label><br>
<input id="empire-state-building" type="checkbox" name="buildings" value="empire-state-building">
<label for="empire-state-building">Empire State Building</label><br>
</fieldset>
And finally the table that holds the cities that he user adds/removes
<table id="building-table" aria-live="polite">
<caption>List of buildings you have selected</caption>
<tr>
<th scope="col">Building name</th>
<th scope="col">Delete Building</th>
</tr>
<tr>
<td>Empire State Building</td>
<td><button>Delete</button> /td>
</tr>
</table>
I thought I was on the right path by using aria-controls="" and aria-live="", but that doesn't seem to be enough for the screen reader to detect the changes. In fact, I don't know if I'm missing something in my markup, or if I need to trigger any alert events or anything like that, to make this work.
aria-live
regions and that may throw things off, but without a page in full context this is not easy to debug. – Diver