Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search result callback doesn't get called. #49

Open
inhoc opened this issue Jan 18, 2023 · 1 comment
Open

Search result callback doesn't get called. #49

inhoc opened this issue Jan 18, 2023 · 1 comment

Comments

@inhoc
Copy link

inhoc commented Jan 18, 2023

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.

@LazyCompiler
Copy link

LazyCompiler commented Feb 14, 2023

I am experiencing the same issue.

Edit: After checking it for a while, it seems that the onResultsUpdate is being invoked, but it fails due to an error that occurs within it.
You can use the .then promise of the onResultsUpdate to confirm it.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants