Mon script fonctionne parfaitement dans tous les navigateurs, mais 11 (bien sûr ...). Je n'arrive pas à comprendre ce que je peux faire de plus. JS Lint passe mon script ... Dit qu'il manque deux points. Voici la fonction entière. Merci pour tout aperçu. Une erreur se produit sur la ligne qui commence "setcurrentList(list) {
" (de l'avant-dernière fonction).SCRIPT1003: Attendu ':' dans IE 11 seulement
Edit: code mis à jour recevoir maintenant l'erreur sur la dernière fonction: getcurrentList()
JQ
generateAllLocationsData = (function() {
var counter = 0;
if (typeof allLocationsData == "undefined") {
allLocationsData = [];
for (var x = 0; x < officesData.children.length; x++) {
for (var y = 0; y < officesData.children[x].departments.length; y++) {
if (officesData.children[x].departments[y].jobs.length > 0) {
for (z = 0; z < officesData.children[x].departments[y].jobs.length; z++) {
counter++;
ids.push(officesData.children[x].departments[y].jobs[z].id);
g_deptHolder[officesData.children[x].departments[y].jobs[z].id] = officesData.children[x].departments[y].name;
}
}
}
}
jobsData = jobsData.sort(function(a, b) {
if (a.title > b.title) {
return 1;
}
if (a.title < b.title) {
return -1
}
return 0;
});
for (var x = 0; x < jobsData.length; x++) {
var dept = g_deptHolder[jobsData[x].id]
if (typeof officesData["All Departments"][dept] == "undefined") {
officesData["All Departments"][dept] = [];
}
officesData["All Departments"][dept].push(jobsData[x]);
}
var sortedObject = [];
Object.keys(officesData["All Departments"]).sort().forEach(function(key) {
sortedObject[key] = officesData["All Departments"][key];
})
officesData.children = officesData.children.sort(function(a, b) {
if (a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1
}
return 0;
})
officesData["All Departments"] = sortedObject;
}
console.log("sorted", officesData);
return officesData;
});
return {
isLoading: function() {
return (!jobsDataLoading && !officesDataLoaidng) ? false : true;
},
getJobsData: function() {
if (this.isLoading() == false) {
return officesData;
} else {
return false;
}
},
getOfficesData: function() {
if (this.isLoading() == false) {
return officesData;
} else {
return false;
}
},
getAllLocationsData: function() {
return generateAllLocationsData();
},
setcurrentList: function(list) {
this.currentList = list.sort(function(a, b) {
if (a.title < b.title) {
return -1;
}
if (a.title > b.title) {
return 1;
}
return 0;
});
},
getcurrentList(): function(list) {
return this.currentList;
}
}
})()
Ouais, syntaxe pour cela et la prochaine item doit être 'name: function (parameters)' mais le vôtre est 'name (parameters)'. Changez juste 'setcurrentList (list)' en 'setcurrentList: function (list)' et la même chose avec 'getcurrentList' ... – cramopy
Cela devrait être' setcurrentList: function (list) {'... et JSLint ne" passe "pas ce code. – Pointy
Copie possible de [Je reçois l'erreur SCRIPT1003: Attendu ':' dans IE 11; (Erreur de code de script Java)] (https://stackoverflow.com/questions/46651124/i-get-the-error-script1003-expected-in-ie-11-java-script-code-error) (et probablement d'autres questions) – ASDFGerte