user2327866
user2327866

Reputation: 3

How to avoid dojo to parse an element


I have a elemetn in my page. I don't control all javascripts used in this page, and seems that in some place my "select" element is being parsed by dojo and changed to a dijit element (dijit.form.select).

This element does not have an attribute "data-dojo-type", so I don't know why it is being changed.

Is there someway to avoid dojo parse this element?

<tr>
    <th scope="row"><div dojoType="dijit.InlineEditBox">Stuff</div></th>
    <td>
        <select>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
        </select>
    </td>
</tr>

Upvotes: 0

Views: 254

Answers (1)

Paul Grime
Paul Grime

Reputation: 15104

I can't see the problem you have in this jsfiddle. The InlineEditBox becomes a dijit, but the <select> does not. The example can try both Dojo 1.6.0 and Dojo 1.8.3:

HTML:

<script>
    var dojoConfig = {
        parseOnLoad: false
    };
</script>
<script>
    var v16 = "https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js.uncompressed.js";
    var v18 = "https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js";
    var dojoUrl = v18;
    document.writeln("<script src='" + dojoUrl + "'></scr" + "ipt>");
</script>
<table border="1">
    <tr>
        <th scope="row">
            <div id="inlineEditBox1" dojoType="dijit.InlineEditBox">Stuff</div>
        </th>
        <td>
            <select id="select1">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
            </select>
        </td>
    </tr>
</table>

JS:

function dojo16ready() {
    if (!(dojoConfig && dojoConfig.parseOnLoad)) {
        dojo.parser.parse();
    }
}

function dojo18ready(parser, registry) {
    function go() {
        console.log("inlineEditBox1", registry.byId("inlineEditBox1"));
        console.log("select1", registry.byId("select1"));
    }
    if (!(dojoConfig && dojoConfig.parseOnLoad)) {
        parser.parse().then(go);
    }
}

function init() {
    console.log("dojo.version", dojo.version);
    if ("function" !== typeof require) {
        // Must require before onload
        dojo.require("dijit.InlineEditBox");
        dojo.addOnLoad(dojo16ready);
    } else {
        require(["dojo/parser", "dijit/registry", "dijit/InlineEditBox"], dojo18ready);
    }
}

init();

Upvotes: 1

Related Questions