Ich habe eine Reihe von Versprechen und es läuft sowohl die Pass-und Failback-Callbacks. Kann nicht herausfinden warum.Versprechen läuft sowohl Erfolg und Misserfolg Callbacks
checkForLists: function() {
var listCheckPromise = [];
$.each(scmap.lists, function(i, list) {
listCheckPromise[i] = $().SPServices({
operation: "GetList",
listName: list.name,
})
})
$.map(listCheckPromise, function(listPromise, index){
listPromise.then(pass(index), fail(index))
})
function pass(index) {
var currentList = scmap.lists[index]
console.log("PASS:", currentList.name, 'list already created')
}
function fail(index) {
var currentList = scmap.lists[index]
console.log("FAIL:", currentList.name, 'does not exist. Creating...')
scmap.createList(currentList)
}
}
versuchen möchten Wie würde ich den Index in diese Funktionen dann bekommen? – Batman
@ Batman könnte 'bind' versuchen, dh' then (pass.bind (null, index), fail.bind (null, index)) ' – Phil
Ja funktioniert gut mit Bind. Danke – Batman