0
votes

I have following Java script class for custom widget. But it is not working. Non of the functions are called. Kindly help, not able to proceed further.

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

1 Answers

0
votes

Change

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

To

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

With lowercase 'c'. Youre connecting to an event on a DOM node, see http://www.w3schools.com/jsref/dom_obj_event.asp