After two callbacks, js cannot get the declared value in the trigger event.

these are two events popup passes cb into the popupHide event

$("body").on("tap", ".removeNumber", function () {
    var _this = $(this);
    api.popup("title", "center", function () {
      console.log(_this);
      //deleteCard(_this)
    })
  });
Nov.04,2021

there is a problem onclick= "popupHide ('+ cb +')" .
explain in detail: cb is a function reference, and string concatenation implicitly calls cb.toString () , and popupHide ( and ) string is probably popupHide (function () {console.log (_ this)}) . After binding to onclick and triggering the event, popupHide points to the global popupHide , and function () {console.log (_ this)} is the newly declared anonymous function, where _ this is indeed undefined .
solution: the onclick event registers the click event through $(.). On ('click', function () {.} after the HTML fragment is inserted into the DOM.
Note: it is best not to try to save cb to global variables, because you have to clean up cb after popup, otherwise memory leaks will occur.

Menu