The code pattern:

    $("#main").html("");
    $("#main").append(bar);

can be simplified to:

    $("#main").html(bar);

In general, the code is, clear, easy to read, and well organized. All the decisions among alternatives are reasonable and straight forward. Doing the simplest thing that might work is a good approach because it avoids adding unneeded complexity to the necessary complexity.