@@ -142,163 +142,168 @@ jQuery.mvc.model
142
142
----------------
143
143
144
144
The model singleton assumes the following responsibilities:
145
- - Maintaining a cache of data proxy instances.
146
- - Providing methods for registering, unregistering and retrieving data proxies.
147
- - Notifiying data proxies when they are registered or removed.
145
+
146
+ * Maintaining a cache of data proxy instances.
147
+ * Providing methods for registering, unregistering and retrieving data proxies.
148
+ * Notifiying data proxies when they are registered or removed.
148
149
149
150
### jQuery.mvc.model.register( [ name] , proxy, options, [ data] )
150
151
151
152
Creates and registers a new named instance of a particular proxy class with the model. If no name is given, one will automatically be generated. The proxy can be configured using a hash of key-value options and may optionally be given an initial data object to act upon.
152
153
153
- // creating a manually named instance
154
- proxy = jQuery.mvc.model.register( "instanceName", ProxyClass, { key: "value" });
155
-
156
- // creating an automatically named instance
157
- proxy = jQuery.mvc.model.register( ProxyClass, { key: "value" });
158
-
159
- // creating a manually named instance with initial data object
160
- proxy = jQuery.mvc.model.register( "instanceName", ProxyClass, { key: "value" }, { foo: 1, bar: "2" })
154
+ // creating a manually named instance
155
+ proxy = jQuery.mvc.model.register( "instanceName", ProxyClass, { key: "value" });
156
+
157
+ // creating an automatically named instance
158
+ proxy = jQuery.mvc.model.register( ProxyClass, { key: "value" });
159
+
160
+ // creating a manually named instance with initial data object
161
+ proxy = jQuery.mvc.model.register( "instanceName", ProxyClass, { key: "value" }, { foo: 1, bar: "2" })
161
162
162
163
### jQuery.mvc.model.remove( {name|proxy} )
163
164
164
165
Removes a proxy instance previously registered with the model.
165
166
166
- // assuming a proxy named "instanceName"
167
- jQuery.mvc.model.remove( "instanceName" );
167
+ // assuming a proxy named "instanceName"
168
+ jQuery.mvc.model.remove( "instanceName" );
168
169
169
- // assuming 'proxy' refers to a registered proxy instance
170
- jQuery.mvc.model.remove( proxy );
170
+ // assuming 'proxy' refers to a registered proxy instance
171
+ jQuery.mvc.model.remove( proxy );
171
172
172
173
### jQuery.mvc.model.has( name )
173
174
174
175
Checks if a proxy has been registered with the model under the given name.
175
176
176
- // assuming a proxy named "instanceName" is registered
177
- jQuery.mvc.model.has( "instanceName" ); // true
177
+ // assuming a proxy named "instanceName" is registered
178
+ jQuery.mvc.model.has( "instanceName" ); // true
178
179
179
- // assuming a proxy named "instanceName" is not registered
180
- jQuery.mvc.model.has( "instanceName" ); // false
180
+ // assuming a proxy named "instanceName" is not registered
181
+ jQuery.mvc.model.has( "instanceName" ); // false
181
182
182
183
### jQuery.mvc.model.get( name )
183
184
184
185
Retrieves an existing instance of a proxy from the model, if one exists.
185
186
186
- // assuming a registered proxy named "instanceName"
187
- proxy = jQuery.mvc.model.get( "instanceName" ); // the proxy instance
187
+ // assuming a registered proxy named "instanceName"
188
+ proxy = jQuery.mvc.model.get( "instanceName" ); // the proxy instance
188
189
189
- // assuming a proxy named "instanceName" is not registered
190
- proxy = jQuery.mvc.model.get( "instanceName" ); // null
190
+ // assuming a proxy named "instanceName" is not registered
191
+ proxy = jQuery.mvc.model.get( "instanceName" ); // null
191
192
192
193
193
194
jQuery.mvc.view
194
195
---------------
195
196
196
197
The view singleton assumes the following responsibilities:
197
- - Maintaining a cache of view mediator instances.
198
- - Providing methods for registering, unregistering or retrieving view mediators.
199
- - Notifiying view mediators when they are registered or unregistered.
198
+
199
+ * Maintaining a cache of view mediator instances.
200
+ * Providing methods for registering, unregistering or retrieving view mediators.
201
+ * Notifiying view mediators when they are registered or unregistered.
200
202
201
203
### jQuery.mvc.view.register( [ name] , mediator, options, [ element] )
202
204
203
205
Creates and registers a new named instance of a particular mediator class with the view. If no name is given, one will automatically be generated. The mediator can be configured using a hash of key-value options. Generally, the mediator should be given a DOM element to act upon. However, for those cases where a mediator has no ties to the DOM the element parameter is made optional. You may pass a string-based selector, a DOM element or a jQuery selector object.
204
206
205
- // creating a manually named instance
206
- mediator = jQuery.mvc.view.register( "instanceName", MediatorClass, { key: "value" }, "body" );
207
+ // creating a manually named instance
208
+ mediator = jQuery.mvc.view.register( "instanceName", MediatorClass, { key: "value" }, "body" );
207
209
208
- // passing a DOM element
209
- mediator = jQuery.mvc.view.register( "instanceName", MediatorClass, { key: "value" }, document.body );
210
-
211
- // passing a jQuery selector object
212
- mediator = jQuery.mvc.view.register( "instanceName", MediatorClass, { key: "value" }, $( "body" ));
213
-
214
- // creating an automatically named instance
215
- mediator = jQuery.mvc.view.register( MediatorClass, { key: "value" }, "body" );
210
+ // passing a DOM element
211
+ mediator = jQuery.mvc.view.register( "instanceName", MediatorClass, { key: "value" }, document.body );
212
+
213
+ // passing a jQuery selector object
214
+ mediator = jQuery.mvc.view.register( "instanceName", MediatorClass, { key: "value" }, $( "body" ));
215
+
216
+ // creating an automatically named instance
217
+ mediator = jQuery.mvc.view.register( MediatorClass, { key: "value" }, "body" );
216
218
217
219
### jQuery.mvc.view.remove( {name|mediator} )
218
220
219
221
Removes a mediator instance previously registered with the view.
220
222
221
- // assuming a mediator named "instanceName" is registered
222
- jQuery.mvc.view.remove( "instanceName" );
223
+ // assuming a mediator named "instanceName" is registered
224
+ jQuery.mvc.view.remove( "instanceName" );
223
225
224
- // assuming 'mediator' refers to a registered mediator instance
225
- jQuery.mvc.view.remove( mediator );
226
+ // assuming 'mediator' refers to a registered mediator instance
227
+ jQuery.mvc.view.remove( mediator );
226
228
227
229
### jQuery.mvc.view.has( name )
228
230
229
231
Checks if a mediator has been registered with the view under the given name.
230
232
231
- // assuming a mediator named "instanceName" is registered
232
- jQuery.mvc.view.has( "instanceName" ); // true
233
+ // assuming a mediator named "instanceName" is registered
234
+ jQuery.mvc.view.has( "instanceName" ); // true
233
235
234
- // assuming a mediator named "instanceName" is not registered
235
- jQuery.mvc.view.has( "instanceName" ); // false
236
+ // assuming a mediator named "instanceName" is not registered
237
+ jQuery.mvc.view.has( "instanceName" ); // false
236
238
237
239
### jQuery.mvc.view.get( name )
238
240
239
241
Retrieves an existing instance of a mediator from the view, if one exists.
240
242
241
- // assuming a registered mediator named "instanceName"
242
- mediator = jQuery.mvc.view.get( "instanceName" ); // the mediator instance
243
+ // assuming a registered mediator named "instanceName"
244
+ mediator = jQuery.mvc.view.get( "instanceName" ); // the mediator instance
243
245
244
- // assuming a mediator named "instanceName" is not registered
245
- mediator = jQuery.mvc.view.get( "instanceName" ); // null
246
-
247
-
248
-
246
+ // assuming a mediator named "instanceName" is not registered
247
+ mediator = jQuery.mvc.view.get( "instanceName" ); // null
248
+
249
+
250
+
249
251
jQuery.mvc.controller
250
252
---------------------
251
253
252
254
The controller singleton assumes these responsibilities:
253
- - Maintaining a cache of constructor functions for commands intended to handle notifications.
254
- - Registering itself as an observer for each notification that it receives a command mapping for.
255
- - Creating and executing instances of the proper command to handle an observed notification.
256
255
256
+ * Maintaining a cache of constructor functions for commands intended to handle notifications.
257
+ * Registering itself as an observer for each notification that it receives a command mapping for.
258
+ * Creating and executing instances of the proper command to handle an observed notification.
257
259
258
260
### jQuery.mvc.controller.register( notificationName, command, options )
259
261
260
262
Registers a command class with the controller. Individual instances of the command will be created and executed for each observed notification of the given name. Created instances can be configured using a hash of key-value options.
261
263
262
- // registering a command for a notification
263
- jQuery.mvc.controller.register( "notificationName", CommandClass, { key: "value" });
264
+ // registering a command for a notification
265
+ jQuery.mvc.controller.register( "notificationName", CommandClass, { key: "value" });
264
266
265
267
### jQuery.mvc.controller.remove( notificationName )
266
268
267
269
Removes a command registered for a particular notifcation from the controller.
268
270
269
- // assuming a notification named "notificationName" has a command registered
270
- jQuery.mvc.controller.remove( "notificationName" );
271
+ // assuming a notification named "notificationName" has a command registered
272
+ jQuery.mvc.controller.remove( "notificationName" );
271
273
272
274
### jQuery.mvc.controller.has( notificationName )
273
275
274
276
Checks if a notification has a command registered with the controller.
275
277
276
- // assuming a notification named "notificationName" has a command registered
277
- jQuery.mvc.controller.has( "notificationName" ); // true
278
+ // assuming a notification named "notificationName" has a command registered
279
+ jQuery.mvc.controller.has( "notificationName" ); // true
278
280
279
- // assuming a notification named "notificationName" has no command registered
280
- jQuery.mvc.controller.has( "notificationName" ); // false
281
+ // assuming a notification named "notificationName" has no command registered
282
+ jQuery.mvc.controller.has( "notificationName" ); // false
281
283
282
284
### jQuery.mvc.controller.get( notificationName )
283
285
284
286
Retrieves a registered command's constructor function from the controller, if one exists.
285
287
286
- // assuming a notification named "notificationName" has a command registered
287
- Command = jQuery.mvc.controller.get( "notificationName" ); // the command's constructor function
288
+ // assuming a notification named "notificationName" has a command registered
289
+ Command = jQuery.mvc.controller.get( "notificationName" ); // the command's constructor function
290
+
291
+ // assuming a notification named "notificationName" has no command registered
292
+ Command = jQuery.mvc.controller.get( "notificationName" ); // null
293
+
294
+
288
295
289
- // assuming a notification named "notificationName" has no command registered
290
- Command = jQuery.mvc.controller.get( "notificationName" ); // null
291
-
292
-
293
296
jQuery.mvc.notifier
294
297
-------------------
295
298
296
299
The notifier assumes these responsibilities:
297
- - Managing the observer lists for each notification in the application.
298
- - Providing a method for attaching observers to a notification's observer list.
299
- - Providing a method for broadcasting a notification.
300
- - Notifying observers of a given notification when it is broadcast.
301
300
301
+ * Managing the observer lists for each notification in the application.
302
+ * Providing a method for attaching observers to a notification's observer list.
303
+ * Providing a method for broadcasting a notification.
304
+ * Notifying observers of a given notification when it is broadcast.
305
+
306
+ * IMPORTANT*
302
307
The notifier should not be used directly by the programmer, unless performing such activities as unit testing.
303
308
304
309
### jQuery.mvc.notifier.register( "notificationName", observer )
0 commit comments