I have an event listener that I'm trying to toggle between a class (which is working) and a data-selection attribute of true/false (which is not). I have the data-selection attribute for div class="dice" already set to false by default.

game.selection = function() {
  $(".dice").on("click", function() {
    $(this).toggle(function () {
      $(this).attr('data-selection', true);
    });
    $(this).toggleClass("active");
  }); 
};

When you pass in two parameters to <code>.<b>attr</b>(<i>attributeName</i>,<i>value</i>)</code>, the second param sets the value. You could write a custom extension, similar to toggleClass to conditionally add or .removeAttr() like this:

<!-- language: lang-js -->
(function($) {
    $.fn.toggleAttr = function(attributeName, state) {
        return this.each(function() {
           if (state) {
             $(this).attr(attributeName,"")
           } else {
             $(this).removeAttr(attributeName)
           }
        });
    };
}(jQuery));

Then use like this:

<!-- language: lang-js -->
$(".class").toggleAttr("boolAt", false);