People using screen readers usually expect links to take them somewhere else in the page on to a different page, while they expect buttons to change something on the page. Since we're in the latter scenario, using a button is more accessible. It's also more natural; with a button, we don't need to provide `#` as the URL or stop the default event when the button is clicked. And, unlike links, buttons can be activated with either the space or the enter key. Finally, clicking a link pointing to `#` with the middle mouse button opens a useless new tab, while buttons do nothing in this case. Now that we only have one "All" link on the page, we no longer need to specify which "All" link we're clicking or which "All" link we are checking, so we're simplifying the code doing so.
18 lines
515 B
JavaScript
18 lines
515 B
JavaScript
(function() {
|
|
"use strict";
|
|
App.CheckAllNone = {
|
|
initialize: function() {
|
|
$("[data-check-all]").on("click", function() {
|
|
var target_name;
|
|
target_name = $(this).data("check-all");
|
|
$("[name='" + target_name + "']").prop("checked", true);
|
|
});
|
|
$("[data-check-none]").on("click", function() {
|
|
var target_name;
|
|
target_name = $(this).data("check-none");
|
|
$("[name='" + target_name + "']").prop("checked", false);
|
|
});
|
|
}
|
|
};
|
|
}).call(this);
|