adobe / adobe/pdf-embed-api-samples
Search result callback doesn't get called.
- Dominant language
- JavaScript
- Stars
- 235
- Forks
- 140
- PR merge metrics
- No merged PRs in 30d
Description
The Adobe git hub examples : pdf-embed-api-samples/Viewer APIs/Search and Zoom APIs/index.js
If the search is done, it must call its callbacks. In this case, "searchCallback". However, this doesn't get called anymore.
It used to call, but at some point it doesn't. Can someone look at this problem?
Actual code looks like this
```
var search = function(searchTerm) {
viewerApis.search(searchTerm)
.then(function(sObj) {
searchObject = sObj;
searchObject.onResultsUpdate(searchCallback). // ==> This callback doesn't get called.
.then(function(result) {
console.log("Registered callback function with onResultsUpdate(): ", result) // ===> This is always false
})
.catch(function(error) {
console.log(error)
});
})
.catch(function(error) {
var errorMsg = "";
if(error.code === "FAIL") {
errorMsg = "No search result found";
} else if(error.code === "INVALID_INPUT") {
errorMsg = "Enter valid search term";
}
document.getElementById("search-result").style.display = "block";
document.getElementById("searchResult-num").innerText = errorMsg;
document.getElementById("search-result").querySelectorAll(".searchResult-btn").forEach(function(element) {
element.style.opacity = "0.2";
element.disabled = true;
});
})
}
//// CALLBACK. This used to called, but no longer gets called.
function searchCallback(searchResult) {
var currentResultIndex = searchResult.currentResult.index;
var totalResults = searchResult.totalResults;
var searchResultItem = document.getElementById("search-result");
searchResultItem.style.display = "block";
document.getElementById("searchResult-num").innerText = "Result " + currentResultIndex + " of " + totalResults;
searchResultItem.querySelectorAll(".searchResult-btn").forEach(function(element) {
element.style.opacity = "0.8";
element.disabled = false;
});
}
```
Expected Behaviour
It should make a callback call.
Actual Behaviour
It doesn't make callback.
Contributor guide
Assessment
This issue has not been assessed yet.