Dijit组合框不会在自定义窗口小部件中呈现 [英] Dijit combobox not rendering in custom widget

查看:91
本文介绍了Dijit组合框不会在自定义窗口小部件中呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Dijit提供的自定义小部件中的组合框。我一直在使用 Dojo关于组合框的教程来指导我。

I am trying to use the combobox provided by Dijit inside of a custom-made widget. I have been using Dojo's tutorial on comboboxes to guide me.

当我实现类似于他们的教程示例的独立网页时,一切正常;但是当我将代码移植到我自定义的小部件中时,它只是将组合框呈现为纯HTML文本框。

When I implement a stand-alone webpage similar to their tutorial examples, everything worked fine; but when I ported the code into my custom-made widget, it just renders the combobox as a plain HTML text box.

这是我的自定义小部件的模板样式: / p>

Here's what my custom widget's template looks like:

<div class='customWidget'>
    ...

    <div dojoAttachPoint="mainDiv" class="mainDiv">
        <div dojoType="dojo.data.ItemFileReadStore" jsId="stateStore" url="states.txt"></div>

        <input dojoType="dijit.form.ComboBox"
               store="stateStore"
               value="California"
               searchAttr="name"
               name="state2" />

        <button dojoAttachEvent="onclick:chooseState">OK</button>
    </div>

    ...
</div>

在窗口小部件代码中,我需要组合框并读取存储:

In the widget code, I require the combobox and read store:

dojo.require("dijit.form.ComboBox");
dojo.require("dojo.data.ItemFileReadStore");

我也尝试将这些包含在< script />在自定义窗口小部件(类似于他们在教程中做的方式),但它没有工作(实际上,似乎脚本标记甚至不被评估,因为我不能引用一个我声明的函数

I also tried putting these includes in a <script/> within the custom widget (similar to the way they do it in the tutorial), but it didn't work (in fact, it appears as if the script tag wasn't even evaluated, since I couldn't reference a function I declared inside of it!)

推荐答案

您的小部件中是否有 widgetsInTemplate 声明?

Do you have widgetsInTemplate in your widget declaration?

  dojo.declare('my.widget.Cool',[ dijit._Widget, dijit._Templated ], {

      widgetsInTemplate: true,

      // rest of widget JS here

   });

这是一篇关于在模板中包含其他小部件的文章。

Here's an article about including other widgets in your template.

这篇关于Dijit组合框不会在自定义窗口小部件中呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆