setCapture(domNode, events: Array);
domNode. Value to remember.
events. Events array. This parameter is optional, its default value is not defined.
The setCapture method remembers specified value.
To execute the example, add a link to PP.js scenario file to HTML page. Create a DOM node and remember its markup:
// Create a DOM element var markup = "<div id=\"test\" onclick=\"alert(12)\"></div>"; var dom = PP.htmlToDOM(markup); console.log("Source markup:"); console.log(dom.outerHTML); console.log(""); // Save the created DOM element PP.setCapture(dom, [onclick]); console.log("Saved markup before its clearing:") // Get saved markup console.log(PP.getCaptureNode() != undefined ? PP.getCaptureNode().outerHTML : "\"\""); console.log(""); // Clear saved markup PP.releaseCapture(dom); console.log("Saved markup after its clearing:") // Get saved markup console.log(PP.getCaptureNode() != undefined ? PP.getCaptureNode().outerHTML : "\"\"");
After executing the example the browser console displays initial HTML markup of the created DOM node, as well as saved markup before and after it is cleared:
Initial markup:
<div id="test" onclick="alert(12)"></div>
Saved markup before it is cleared:
<div id="test" onclick="alert(12)"></div>
Saved markup after it is cleared:
""
See also: