Es6 modules - Best practice for events

472 views Asked by At

I have some events, and to make them a bit neater I have grouped them together in a module

export function myevents () {


$('.btn').on('click', function() {
   //do stuff
  });


 $(document).on('click', ".delete-product", function(){

  //Do stuff

 });

}

There are loads of them but they are only really related by the fact they are dom events. The events mainly update the DOM and perform ajax request.

The problem is it is just a bit messy. What is the best way to tackle this. Should I add them to a class?

I am using Jquery and am stuck with it for now.

0

There are 0 answers