fac-12 / dater

Week 8 project using Express and Handlebars
0 stars 0 forks source link

Clever frontend js, but is it necessary? #28

Open BartBucknill opened 6 years ago

BartBucknill commented 6 years ago

You have:

button.addEventListener('click', function(e){
    var tag = e.target.textContent.replace(' ', '-');
    window.location.href='/result/'+tag;

in your frontend js. I've not seen this before, and I definitely learnt something. But is it necessary? Given that you have the page redirecting/refreshing anyway, I think you could just accomplish the same thing with an html form, using input type of 'checkbox' and method set to 'get'. If I'm right, then by doing this you could avoid having any frontend js.

If on the other hand you wanted to avoid refreshing/redirecting the page, you could make an xhr request and populate the page using frontend dom manipulation when the response comes back. However, you are not currently doing this.