dojo自定义小部件无效

时间:2012-08-23 12:05:55

标签: dojo

我有自定义小部件的Java脚本类。但它没有用。不调用任何函数。请帮助,不能继续前进。

dojo.provide("FancyCounter");

dojo.require("dijit._Widget");
dojo.require("dojo.parser");


dojo.declare("FancyCounter",[dijit._Widget],
{
//counter
_i:0,


buildRendering: function()
{
    //create DOM
    this.domNode = dojo.create("button",{innerHTML:this._i});
},

postCreate: function()
{
    this.connect(this.domNode,"onClick","increment");

},

increment:function()
{
    //you need to update dom in order to refresh display i believe
    this.domNode.innerHTML = ++this._i;
},
});
dojo.ready(function(){
   dojo.parser.parse();
});

/////html code
<span data-dojo-type ="FancyCounter"></span>

1 个答案:

答案 0 :(得分:0)

更改

this.connect(this.domNode,"onClick","increment");

this.connect(this.domNode,"onclick","increment");

小写'c'。您要连接到DOM节点上的事件,请参阅http://www.w3schools.com/jsref/dom_obj_event.asp