Le code suivant est redondant --- la même fonction anonyme apparaît trois fois.En Javascript, comment puis-je refactoriser des fonctions anonymes répétées?
Comment le refactoriser?
$(".operation").resizable({
create: function(event, ui) {
var width = $(".operation").width()
$("#width span.text").text(width)
},
resize: function(event, ui) {
var width = $(".operation").width()
$("#width span.text").text(width)
},
stop: function(event, ui) {
var width = $(".operation").width()
$("#width span.text").text(width)
},
})
+1, mais en supposant qu'il est déjà en cours d'exécution à l'intérieur d'une fermeture/fonction, la fermeture supplémentaire n'est pas nécessaire. –