我有一个带有已定义模块的文件,例如:
define([
"xstyle/css!./less/layout.less",
"dojo", "dojo/parser", "dojo/store/Memory", "dojo/dom-style", "dojo/dom-construct", "dojo/store/Observable", "dojo/_base/declare", "dojo/query", "dojo/dom-attr", "dojo/on", "dojo/request/xhr", "dojo/sniff", "dojo/keys", "dojo/string", "dojo/topic", "dojo/date/locale", "dojo/date/stamp", "dojo/date", "dojo/store/JsonRest", "dojo/number", "dojo/_base/lang",
"dijit", "dijit/PopupMenuItem", "dijit/Menu", "dijit/MenuItem", "dijit/form/Select", "dijit/Dialog", "dijit/layout/ContentPane", "dijit/Toolbar", "dijit/form/Button", "dijit/form/ValidationTextBox", "dijit/form/FilteringSelect",
"dojox/layout/TableContainer",
"dgrid/editor", "dgrid/Keyboard", "dgrid/selector"
],
function(
less,
dojo, parser, MemoryStore, domStyle, domConstruct, Observable, declare, query, domAttr, on, xhr, has, keys, string, topic, localeDate, stamp, dojoDate, JsonRest, dojoNumber, lang,
dijit, PopupMenuItem, Menu, MenuItem, Select, Dialog, ContentPane, Toolbar, Button, TextBox, FilteringSelect,
TableContainer,
editor, Keyboard, selector
) {
function createWidgetSpecified(root, collectionsToolbar){
...
}
function getCollectionGrid(root, fieldCode, style){
....
}
function filterDocumentTypeFieldsForNonByte(documentData){
.....
}
...
return declare(Dialog, {
...,
...,
constructor: function(args){
lang.mixin(this, args);
},
createIssuerInfo: function(issuerData){
...
},
createMatcher: function(root){
...
},
...
});
});
我想和另一个混合。对我来说重要的想法是:替换或添加新函数(未在类中声明)。例如,我想用它的新版本替换 createWidgetSpecified,并添加另外两个函数,如:startSave、startDelete。我怎样才能做到这一点 ?
我没有提到那些只在运行时知道的功能。我的意思是我定义的模块是使用参数类型 = 26 创建的。我想从文件中加载该函数:../js/fortype/26/document.js 用于类型 26
比如: var moduleObject = new Module({type:26}); 我想动态加载类型 26 的函数