아래 스 니펫은 다른 동료가 제공 한 더 큰 라이브러리의 함수입니다. 이 함수는 프로토 타입의 다른 메서드에서 호출됩니다. 그래서jquery 함수 매개 변수, 객체 및 변수
<spellResult .....>
<c o=0 l=1 s=1>string string string />
<c o=10 l=1 s=1>string string string />
</spellResult>
parseResults: function(results) {
var self = this;
this.results = [];
var spellcheckFound = $(results).find('c');
$(results).find('c').each(function() {
var $this = $(this),
offset = $this.attr('o'),
length = $this.attr('l');
self.results.push({
word: self.text.substr(offset, length),
suggestions: $this.text().split(/\s/)
});
});
this.displayResults();
},
:
이 이- 가 어떻게
results
매개 변수this.results
다를 않습니다results
매개 변수는 다음과 같이 보입니다 XML의 문자열입니다? this.results = [];
행이 결과 매개 변수를 지우지 않습니까?self.results
이 다른 객체/변수이거나 다른 객체/변수 중 하나에 대한 참조입니까?- 또 하나의 초보자 질문 - 여기에
$(results)
은 무엇입니까?
나는이 일을하기 위해 노력하고있어 내 머리카락을 당겨 왔어, 그래서 어떤 도움을 주셔서 감사합니다.
'console.log()'묶음을 각 객체가 어떻게 변하는 지 확인하십시오. 예를 들어'this.results = []; 다음에'console.log (self.results)'를 추가하여 비어 있는지 확인하십시오. – Jasper
self는 예약어입니다. 나쁜, 나쁜, 나쁜 에스터. 나쁜. 편집 : 확인 어쩌면 예약 아니지만 쉽게 window.self와 혼동 – jbabey
' 문자열 문자열 문자열 />'확실히 XML이 맞지 않지만 올바르게 게시하지 않은 것 같습니다. 게시하기 전에 명백한 구문 오류가 코드에 없는지 확인해야합니다. –