openCursorのonsuccessイベントに2つの関数をバインドできますか? 私は最初の行にある初期値を設定するためにこれを行いたいと思います。openCursorの2つの成功
;(function() {
\t var variables = {}
\t
\t var myTransaction = myDatabase.transaction(['myData'])
\t var myObjectStore = myTransaction.objectStore('myData')
\t var myIndex = myObjectStore.index('myIndex')
\t var myRange = IDBKeyRange.only(0)
\t var myRequest = myIndex.openCursor(myRange)
\t myRequest.onsuccess = firstRow // This is what I'm wondering about
\t myRequest.onsuccess = mySuccess // Can I have two onsuccess events?
\t
\t function firstRow(response) {
\t \t var result = response.target.result
\t \t if (result) {
\t \t \t variables.custid = result.value.custid
\t \t \t // Notice there's no result.continue() here
\t \t }
\t }
\t function mySuccess(response) {
\t \t var result = response.target.result
\t \t if (result) {
\t \t \t if (result.value.custid === variables.custid) {
\t \t \t \t // yay
\t \t \t }
\t \t \t result.continue()
\t \t }
\t }
}())