简体   繁体   中英

Creating a widget in Dojo

I am developing a mobile application using the Dojo Toolkit. I want to make a widget of the following:

<div data-dojo-type="dojox.mobile.ListItem" data-dojoprops="moveTo:'breakdown'">
    <div>Maximum: Some value</div>
</div>

I want to be able to use the widget like this:

<div data-dojo-type="dojox.mobile.RoundRectList">
    <div data-dojo-type="MyWidget" data-dojo-props="maximum:'1200'"></div>
</div>

And here is what I did so far:

require(
    [ "dojo/_base/declare", "dojo/parser", "dojo/ready",
        "dojox/mobile/ListItem", "dijit/_WidgetBase",
        "dijit/_TemplatedMixin" ],

        function(declare, parser, ready, ListItem, _WidgetBase, _TemplatedMixin) {
            declare("MyWidget", [ ListItem, _WidgetBase, _TemplatedMixin ], {

                templateString: "<div>"         
                              + "<div>Maximum: <span data-dojo-attach-point='maximumNode'></span></div>"
                              + "</div>",

                maximum : "unknown",
                _setMaximumAttr : { node : "maximumNode", type : "innerHTML" },

                buildRendering : function() {
                    this.inherited(arguments);
                }
            });

            ready(function() {
                parser.parse();
            });
        });

I get no error or somthing like that, the page is not loading. What is wrong with that code?

I wrote this quick example.

From your code snippet I suspect that you might want to do something like this http://jsfiddle.net/hJJUD/7/

I recommend not changing the template from that listItem, Instead try to play with the properties it has. Take a look at this documentation http://dojotoolkit.org/reference-guide/1.8/dojox/mobile/ListItem.html

If you find that you need anything else let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM