我已经在MVC4和使用淘汰赛中创建了网站。我收到错误未捕获类型错误号不是按钮单击下面的代码行中的函数。
var sum = newIdea2[0].TotalImpact() + newIdea2[0].TotalPracticality() + newIdea2[0].TotalAlignment();
以下是完整的代码行: -
function SubmitIPAOnClick(data) {
var ideaId = 0;
if ($.isNumeric(data.Id)) {
ideaId = data.Id;
} else {
ideaId = data.Id();
}
ajaxRequest("post", "/api/IdeaAPI/UpdateIPA/" + (ideaId || "") + "/" + (loginUserId || ""), data, null)
.done(function (result) {
var newIdea2 = [result];
//var ideaCount = 0;
//ko.utils.arrayForEach(self.ideas(), function (newIdea) {
// if (ideaId == newIdea.Id()) {
// self.ideas.replace(self.ideas()[ideaCount], new Idea(newIdea2[0]))
// }
// ideaCount++;
//});
var idea = ko.utils.arrayFirst(self.ideas(), function (currentIdea) {
return currentIdea.Id() == ideaId;
});
if (idea) {
idea.MyAlignment(newIdea2[0].MyAlignment);
idea.MyImpact(newIdea2[0].MyImpact);
idea.MyPracticality(newIdea2[0].MyPracticality);
idea.TotalAlignment(newIdea2[0].TotalAlignment);
idea.TotalImpact(newIdea2[0].TotalImpact);
idea.TotalPracticality(newIdea2[0].TotalPracticality);
var avg = ko.computed(function () {
var sum = newIdea2[0].TotalImpact() + newIdea2[0].TotalPracticality() + newIdea2[0].TotalAlignment();
if (sum > 0) {
return Math.round((sum / 3) * 10) / 10;
}
else {
return 0;
}
}).extend({ notify: 'always' });
idea.Average(avg);
}
})
.fail(function (jqxhr, textStatus, error) {
console.log("Request Failed" + textStatus + "," + error + ",," + jqxhr.toString());
});
}
self.SubmitIPA = function (data, event) {
var $this = $(event.target);
SubmitIPAOnClick(data);
HideRatingsSection2($this);
};
self.SearchIdeas = function (data) {
var searchText = $("#txtSearchIdeas").val().toLowerCase();
var SearchSucessString = "";
var appendString = "";
var goalFound = false;
var userFound = false;
var ideaTitleFound = false;
var goalTagsFound = false;
for (var ideaCount = 0; ideaCount < self.ideas().length; ideaCount++) {
var tempIdea = self.ideas()[ideaCount];
if (searchText == "") {
tempIdea.ShowThisIdea(true);
} else if (tempIdea.GoalName().toLowerCase().indexOf(searchText) != -1) {
goalFound = true;
tempIdea.ShowThisIdea(true);
} else if (tempIdea.FullName().toLowerCase().indexOf(searchText) != -1) {
userFound = true;
tempIdea.ShowThisIdea(true);
} else if (tempIdea.Goal().Tags.toLowerCase().indexOf(searchText) != -1) {
goalTagsFound = true;
tempIdea.ShowThisIdea(true);
} else if (tempIdea.Title().toLowerCase().indexOf(searchText) != -1) {
ideaTitleFound = true;
tempIdea.ShowThisIdea(true);
}
else {
tempIdea.ShowThisIdea(false);
}
}
请让我知道这个问题的解决方案,因为我正试图让它解决。