dojox移动手风琴使用dojo mvc无法正常工作

时间:2013-11-11 06:28:07

标签: dojo dojox.mobile

我尝试使用dojox mvc repeat和group创建dojox移动手风琴。我甚至尝试在dojox.mvc.Repeat的data-dojo-props中使用removeRepeatNode:true,我得到一个JS错误

dojo / parser :: parse()错误 TypeError:b._at未定义

我正在使用dojo 1.9

对此有任何帮助吗?

1 个答案:

答案 0 :(得分:0)

我在dojo-interest mailing list中看到了同样的问题。 dojox/mvc/Repeat是一个已弃用的模块。 dojox/mvc/WidgetList取代它。

下面的代码演示了dojox/mobile/Accordion如何与dojox/mvc/WidgetList一起使用:

<!DOCTYPE html>
<html>
    <head>
        <title>Accordion</title>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojox/mobile/deviceTheme.js"
            data-dojo-config="mblThemeFiles: ['base', 'Accordion']"></script>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"
            data-dojo-config="async: 1, parseOnLoad: 0"></script>
        <script type="text/javascript">
            require([
                "dojo/_base/declare",
                "dojox/mvc/at",
                "dojox/mobile/parser",
                "dojox/mobile/Accordion",
                "dojox/mvc/WidgetList",
                "dojox/mvc/Output",
                "dojox/mvc/_InlineTemplateMixin",
                "dojox/mobile",
                "dojox/mobile/ContentPane"
            ], function(declare, at, parser, Accordion){
                declare("my.Accordion", Accordion, {
                    addChild: function(widget, index){
                        this.inherited(arguments, [widget, index * 2]);
                    }
                })
                window.at = at;
                window.model = [
                    {title: "foo", content: "Foo", selected: true},
                    {title: "bar", content: "Bar"},
                    {title: "baz", content: "Baz"}
                ];
                parser.parse();
            });
        </script>
    </head>
    <body>
        <div data-dojo-type="my.Accordion"
            data-dojo-mixins="dojox/mvc/WidgetList,dojox/mvc/_InlineTemplateMixin"
            data-dojo-props="children: model"
            data-mvc-child-type="dojox/mobile/ContentPane"
            data-mvc-child-mixins="dojox/mvc/Templated"
            data-mvc-child-props="label: at(this.target, 'title'), selected: at(this.target, 'selected')">
            <script type="dojox/mvc/InlineTemplate">
                <div>
                    <span data-dojo-type="dojox/mvc/Output"
                        data-dojo-props="value: at('rel:', 'content')"></span>
                </div>
            </script>
        </div>
    </body>
</html>

一些技巧是:

有关详情,请参阅my mailing list reply

最佳, 晃