1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| class Carte {
constructor({reference = "", intitule = "", annee = "", interest = ""}){
this.reference = reference,
this.intitule = intitule,
this.annee = annee,
this.interest = interest
}
add(){ /// qui permet d'afficher les informations dans une div
document.getElementById("info_carte").innerHTML =
`<form action="" id="cpa_edit">
<div><input type="text" id="fd_reference" value="${this.reference}"></div>
<div><input type="text" id="fd_intitule" value="${this.intitule}"></div>
<div class="my-rating">${this.interest}"</div>
<button type="submit">Soumettre</button>
</form>`
}
rate(){ /// j'utilise ici la notation par étoiles jQuery avec starRating
$(".my-rating").starRating({
useFullStars: true,
emptyColor:'transparent',
strokeColor: 'black',
starSize: 22,
readOnly: false,
hoverColor:'grey',
activeColor:'black',
ratedColor:'gold',
ratedColors:'yellow',
useGradient:false,
initialRating: this.interest,
disableAfterRate:false,
onClick: function(currentIndex, currentRating, $el){
return currentRating;
}
});
}
update(){
$.ajax({
url:"monfichier.php?",
type:"POST",
data:{
"reference":$("fd_reference").val(),
"intitule":$("fd_intitule").val(),
"interest":this.interest ?? currentRating //// et c'est là que systématiquement ça renvoie "currentRating" is not defined
},
success:function(data){
M.toast({html: 'Données de la carte mises à jour !', displayLength: 5000, classes: 'toast_success'});
},
error:function(err){
M.toast({html: 'Erreur :' + err, displayLength: 5000, classes: 'toast_error'});
}
})
}
} |
Partager