最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dojo's dojomethod programmatically? - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 8

Just 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
 }
});
发布评论

评论列表(0)

  1. 暂无评论