Manipulating the dom of two separate html documents displayed in two separate kinds in enyo app

Not sure if the title makes any sense...
I am displaying html content in two different panels. I'm trying to parse out content from one html document using something like: var paras = document.getElementsByTagName("p");
but its interacting with both documents. How do I target only one at a time.
Assume the content is attached in two elements named doc1 and doc2.

Comments

  • Unless you're working with frames, you're likely only working with one document in your app. Each panel isn't a separate document but rather a DOM subtree within the same document. As a result, calls on document will interact with all nodes in every panel.

    What you probably want to use is querySelectorAll(selector) on the panel node.

    http://jsfiddle.net/njfHE/
    enyo.kind({
    name: "ex.App",
    kind: "Panels",
    components: [
    {name: "p1", allowHtml: true, content: "Panel 1"},
    {name: "p2", allowHtml: true, content: "Panel 2"} ], rendered: enyo.inherit(function(sup) { return function() { sup.apply(this, arguments); if(this.hasNode()) { var n = this.$.p1.hasNode(); // alerts Panel 1 alert(n.querySelectorAll("b").item(0).innerText); } }; }) });
Sign In or Register to comment.