Is there a way to define a dojo/method programmatically, in a JavaScript function? (Instead of defining it through script type="dojo/method" within a declarative widget, for example.)
Is there a way to define a dojo/method programmatically, in a JavaScript function? (Instead of defining it through script type="dojo/method" within a declarative widget, for example.)
Share Improve this question edited Aug 28, 2017 at 3:09 Cœur 38.8k25 gold badges205 silver badges277 bronze badges asked Oct 1, 2010 at 8:51 AriodAriod 5,85122 gold badges77 silver badges104 bronze badges 1- 1 Does this sitepen./blog/2007/09/21/… do anything for you? – mplungjan Commented Oct 1, 2010 at 9:18
2 Answers
Reset to default 8Just override it directly on a widget. For example, if you wrote dojo/method
for abc
, do it like that:
var myWidget = ...;
myWidget.abc = function(/* args from dojo/method */){
// the body of dojo/method
};
Maybe the best option in your case is extend widget prototype, do it like that:
dojo.require("dijit.OneDijit");
dojo.extend(dijit.OneDijit, {
newMethod:function(/* method args */){
// body of method
}
});