Dojo fiddle
This JSFiddle is configured and ready to use for testing the Dojo framework.
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/claro/claro.css">
JavaScript
require([
"dojo/dom-construct",
"dojo/_base/window",
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_OnDijitClickMixin",
"dijit/_TemplatedMixin",
"dojo/on",
"dojo/_base/lang",
"dojo/domReady!"
], function (domconstruct, window, declare, _WidgetBase, _OnDijitClickMixin, _TemplatedMixin, on, lang) {
// Template mock
var template = "<div class=\"${baseClass}\" data-dojo-attach-point=\"searchtextbox\"><p>here your widget</p></div>";
var MyWidget = declare([_WidgetBase, _OnDijitClickMixin, _TemplatedMixin], {
templateString: template,
// your custom code goes here
_onClick: function(event) {
console.log( "Click event in widget "+event );
this.onCustomEvent(event.x);
},
onCustomEvent: function() {
},
postCreate : function () {
on(this.searchtextbox,"click",lang.hitch(this, "_onClick"));
}
});
var node = domconstruct.create("div", window.body());
console.log(node);
var mywidget = new MyWidget({});
mywidget.startup();
domconstruct.place(mywidget.domNode,window.body());
mywidget.on("customevent", function(data){
console.log( " received notification "+data );
});
});