在dojo filteringSelectWidget之前和之后添加span标记

时间:2010-11-12 20:49:39

标签: javascript dojo

我正在尝试在我刚创建的dojo filteringSelect小部件标记之前和之后插入一个标记。我怎么能在道场做到这一点?

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js">
    </script>
    <script type="text/javascript">
        dojo.require("dijit.form.FilteringSelect");
        var filteringSelect = new dijit.form.FilteringSelect({
            id: "test"
        }, "test");
    </script>
    />
</head>
<body>
    <div aria-expanded="false" widgetid="test" role="combobox" class="dijit dijitReset dijitInlineTable dijitLeft dijitComboBox" id="widget_test" dojoattachevent="onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse" dojoattachpoint="comboNode" wairole="combobox" tabindex="-1">
        <div style="overflow: hidden;">
            <div role="presentation" class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonActive" dojoattachpoint="downArrowNode" wairole="presentation" dojoattachevent="onmousedown:_onArrowMouseDown,onmouseup:_onMouse,onmouseenter:_onMouse,onmouseleave:_onMouse">
                <div class="dijitArrowButtonInner">
                    ?
                </div>
                <div class="dijitArrowButtonChar">
                    ?
                </div>
            </div>
            <div class="dijitReset dijitValidationIcon">
                <br>
            </div>
            <div class="dijitReset dijitValidationIconText">
                ?
            </div>
            <div class="dijitReset dijitInputField">
                <input aria-owns="test_popup" value="United States" aria-required="true" tabindex="0" id="test" aria-invalid="false" aria-autocomplete="list" aria-haspopup="true" role="textbox" autocomplete="off" class="dijitReset" dojoattachevent="onkeypress:_onKeyPress,compositionend" dojoattachpoint="textbox,focusNode" wairole="textbox" waistate="haspopup-true,autocomplete-list" type="text"><input name="" style="display: none;" type="text">
            </div>
        </div>
    </div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

好吧,如果你绝对想要在你的Javascript和HTML之间拆分FilteringSelect的定义,我认为你可以做一些丑陋的事情:

var targetInput = dojo.byId("test");
var spanWrapper = dojo.create("span");

dojo.place(wrapperSpan, targetInput, "replace");
dojo.place(targetInput, wrapperSpan);

dojo.require("dijit.form.FilteringSelect");

var filteringSelect = new dijit.form.FilteringSelect({
    id: "test"
}, "test");