0

我有以下用于自定义小部件的 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>
4

1 回答 1

0

改变

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

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

使用小写的“c”。您正在连接到 DOM 节点上的事件,请参阅http://www.w3schools.com/jsref/dom_obj_event.asp

于 2012-08-23T12:15:40.580 回答