1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/***************************************************************
USAGE:
1. Include this script before your client object class definition.
2. Call the MsAjaxMixin right after your function definition,
so that it attaches the necessary methods to the prototype
RadControlsNamespace.MsAjaxMixin.Initialize(RadMenu, 'RadMenu');
3. Change your client object initialization:
- rework your construction logic so that the constructor accepts only one element -- a DOM node.
- pass any additional data to an Initalize() method after the object is constructed.
4. Call the initializeBase method in the constructor of your JavaScript object:
function RadMenu(element)
{
...
if (typeof(RadMenu.initializeBase) == "function")
{
RadMenu.initializeBase(this, [element]);
}
}
5. Create a static factory method that will create a new object. Let it accept a client ID only:
RadMenu.Create = function(clientID)
{
return new RadMenu(document.getElementById(clientID));
}
6. Change your InitScript rendering:
- it should not call new RadMenu() directly. use the factory method instead: RadMenu.Create()
Look below for a sample RadMenu.Create() implementation. That method will create your object and
register it with the MS AJAX script runtime if it is present on the page.
***************************************************************/
//RadMenu.Create = function ()
//{
// var clientID = arguments[0];
//
// if (typeof ($create) == "function")
// {
// //the global RadMenu function object
// var type = this;
//
// //{name : 'value'} will trigger a menuInstance.set_name('value');
// var properties = {};
//
// //{itemClick : OnItemClick} will trigger a menuInstance.add_itemClick(OnItemClick);
// var events = {};
//
// //{"Treeview" : "RadTreeView1} will trigger a menuInstance.set_Treeview($find('RadTreeView1'));
// var references = {};
//
// //the DOM element that this component will attach to. crucial for partial updates and disposes
// var domElement = $get(clientID);
// return $create(type, properties, events, references, domElement);
// }
// else
// {
// var element = document.getElementById(clientID);
// return new this(element);
// }
//}
if (typeof window.RadControlsNamespace == "undefined")
{
window.RadControlsNamespace = {};
}
if (
typeof(window.RadControlsNamespace.MsAjaxMixin) == "undefined" ||
typeof(window.RadControlsNamespace.MsAjaxMixin.Version) == null ||
window.RadControlsNamespace.MsAjaxMixin.Version < 1
)
{
RadControlsNamespace.MsAjaxMixin =
{
Version : 1,
Initialize : function(type, typeName)
{
if (typeof(type.registerClass) != "function")
{
return;
}
type.inheritsFrom(Sys.UI.Control);
type.registerClass(typeName, Sys.UI.Control, Sys.IDisposable);
type.prototype.initialize = function()
{
Sys.UI.Control.callBaseMethod(this, 'initialize');
}
type.prototype.dispose = function()
{
Sys.UI.Control.callBaseMethod(this, 'dispose');
this.Dispose();
}
}
}
}
//BEGIN_ATLAS_NOTIFY
if (typeof(Sys) != "undefined")
{
if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
{
Sys.Application.notifyScriptLoaded();
}
}
//END_ATLAS_NOTIFY
|