lundi 24 juillet 2017

JavaScrip module pattern function or jQuery delegate

I'd loike to know which solutions better to use module pattern or write a handle function for an input element action?

<button type="button" onClick="main.update.buttonClick">Click</button>

(function($) { 
 'use strict'; 
 window.main.update = window.main.update || ();

 main.update.init = function() { ... };

 main.update.buttonClick = function() { ... }; })(jQuery);

or

 <button id="update" type="button">Click</button>

(function($) { 
 'use strict'; 
 window.main.update = window.main.update || ();

 main.update.init = function() { 
  $("#update").on("click", functio() { ... });
 };

What is the better solution or there is another more better one, please?

Aucun commentaire:

Enregistrer un commentaire