我在使用 dojo 内联模板时遇到以下问题: 我通过在以下标签之间定义模板在 html 页面中创建模板(它还集成了 mvc)
`<script id="createNewItem" type="text/template">
<div>
<div data-dojo-type='dijit/TitlePane' data-dojo-props='open:false'>
<div class='accordionRev'>
<input type="number" name="qty" placeholder="Quantity (required)" data-dojo-type="dojox.mobile.TextBox" class='quantity' data-dojo-props="value: at('rel:','quantity'), class:at('rel:', 'quantityErr')" onchange="cntrl.createQuoteFields(true, this, '{{lineNumber}}');" onkeypress="cntrl.quantityHandler.call(this, '{{lineNumber}}')" onpaste="cntrl.pastehandler.call(this)" tabindex=0/>
</div>
</div>
</div>
</script>'
I will be using this template in another page like this
`<ul id="rfqTitlePane" class="hide"
data-dojo-type="dojox/mvc/WidgetList"
data-dojo-mixins="dojox/mvc/_InlineTemplateMixin"
data-dojo-props="children: at(cntrl.createQuoteList,'items').direction(at.from)"
data-mvc-child-type="dojox/mvc/Templated"
data-mvc-child-props="clickable: true, variableHeight: 'true',
indexAtStartup: this.indexAtStartup,
customTitle: at(this.target, 'title').direction(at.both), titlePaneDOM:at(this.target,'displayDetails').direction(at.from).transform({format:custom.helpers.RequestMarkup})">
<script type="dojox/mvc/InlineTemplate">
<li>
${titlePaneDOM}
</li>
</script>
</ul>`
I am getting "Unable to resolve constructor for: '"dojox.mobile.TextBox"'" error. I actually defined textbox before the template gets loaded. I am not sure where its going wrong
这个问题
似乎包含错误的降价,所以我建议修复它,以便提供更好的答案。同时,我可以说的一些事情是:
- 您可能需要在运行模板之前尝试导入 dojox/移动/文本框模块。
- 最近发布的 Dojo 更喜欢 AMD 格式
data-dojo-type
例如data-dojo-typ="dojox/mobile/TextBox"
. - dojox/mvc/InlineTemplateMixin 查看
<script type="dojox/mvc/InlineTemplate">
而不是<script type="text/template">
。
希望这有帮助。
最佳, 阿基拉