43 | | // ### Get a selector's first subview |
44 | | // |
45 | | // Fetches the first subview that matches a given `selector`. |
46 | | // |
47 | | // If no `selector` is provided, it will grab the first subview |
48 | | // attached to the view's root. |
49 | | // |
50 | | // Useful when a selector only has one subview at a time. |
| 52 | /** |
| 53 | * Fetches the first subview that matches a given `selector`. |
| 54 | * |
| 55 | * If no `selector` is provided, it will grab the first subview |
| 56 | * attached to the view's root. |
| 57 | * |
| 58 | * Useful when a selector only has one subview at a time. |
| 59 | * |
| 60 | * @param {string} selector A jQuery selector. |
| 61 | * |
| 62 | * @return {Backbone.View} The view. |
| 63 | */ |
55 | | |
56 | | // ### Register subview(s) |
57 | | // |
58 | | // Registers any number of `views` to a `selector`. |
59 | | // |
60 | | // When no `selector` is provided, the root selector (the empty string) |
61 | | // is used. `views` accepts a `Backbone.View` instance or an array of |
62 | | // `Backbone.View` instances. |
63 | | // |
64 | | // --- |
65 | | // |
66 | | // Accepts an `options` object, which has a significant effect on the |
67 | | // resulting behavior. |
68 | | // |
69 | | // `options.silent` – *boolean, `false`* |
70 | | // > If `options.silent` is true, no DOM modifications will be made. |
71 | | // |
72 | | // `options.add` – *boolean, `false`* |
73 | | // > Use `Views.add()` as a shortcut for setting `options.add` to true. |
74 | | // |
75 | | // > By default, the provided `views` will replace |
76 | | // any existing views associated with the selector. If `options.add` |
77 | | // is true, the provided `views` will be added to the existing views. |
78 | | // |
79 | | // `options.at` – *integer, `undefined`* |
80 | | // > When adding, to insert `views` at a specific index, use |
81 | | // `options.at`. By default, `views` are added to the end of the array. |
| 68 | /** |
| 69 | * Register subview(s) |
| 70 | * |
| 71 | * Registers any number of `views` to a `selector`. |
| 72 | * |
| 73 | * When no `selector` is provided, the root selector (the empty string) |
| 74 | * is used. `views` accepts a `Backbone.View` instance or an array of |
| 75 | * `Backbone.View` instances. |
| 76 | * |
| 77 | * --- |
| 78 | * |
| 79 | * Accepts an `options` object, which has a significant effect on the |
| 80 | * resulting behavior. |
| 81 | * |
| 82 | * `options.silent` – *boolean, `false`* |
| 83 | * > If `options.silent` is true, no DOM modifications will be made. |
| 84 | * |
| 85 | * `options.add` – *boolean, `false`* |
| 86 | * > Use `Views.add()` as a shortcut for setting `options.add` to true. |
| 87 | * |
| 88 | * > By default, the provided `views` will replace |
| 89 | * any existing views associated with the selector. If `options.add` |
| 90 | * is true, the provided `views` will be added to the existing views. |
| 91 | * |
| 92 | * `options.at` – *integer, `undefined`* |
| 93 | * > When adding, to insert `views` at a specific index, use |
| 94 | * `options.at`. By default, `views` are added to the end of the array. |
| 95 | * |
| 96 | * @param {string} selector A jQuery selector. |
| 97 | * @param {array|object} views The subviews for the main view. |
| 98 | * @param {} options |
| 99 | * |
| 100 | * @return |
| 101 | */ |
136 | | |
137 | | // ### Add subview(s) to existing subviews |
138 | | // |
139 | | // An alias to `Views.set()`, which defaults `options.add` to true. |
140 | | // |
141 | | // Adds any number of `views` to a `selector`. |
142 | | // |
143 | | // When no `selector` is provided, the root selector (the empty string) |
144 | | // is used. `views` accepts a `Backbone.View` instance or an array of |
145 | | // `Backbone.View` instances. |
146 | | // |
147 | | // Use `Views.set()` when setting `options.add` to `false`. |
148 | | // |
149 | | // Accepts an `options` object. By default, provided `views` will be |
150 | | // inserted at the end of the array of existing views. To insert |
151 | | // `views` at a specific index, use `options.at`. If `options.silent` |
152 | | // is true, no DOM modifications will be made. |
153 | | // |
154 | | // For more information on the `options` object, see `Views.set()`. |
| 156 | /** |
| 157 | * Add subview(s) to existing subviews |
| 158 | * |
| 159 | * An alias to `Views.set()`, which defaults `options.add` to true. |
| 160 | * |
| 161 | * Adds any number of `views` to a `selector`. |
| 162 | * |
| 163 | * When no `selector` is provided, the root selector (the empty string) |
| 164 | * is used. `views` accepts a `Backbone.View` instance or an array of |
| 165 | * `Backbone.View` instances. |
| 166 | * |
| 167 | * Use `Views.set()` when setting `options.add` to `false`. |
| 168 | * |
| 169 | * Accepts an `options` object. By default, provided `views` will be |
| 170 | * inserted at the end of the array of existing views. To insert |
| 171 | * `views` at a specific index, use `options.at`. If `options.silent` |
| 172 | * is true, no DOM modifications will be made. |
| 173 | * |
| 174 | * For more information on the `options` object, see `Views.set()`. |
| 175 | * |
| 176 | * @param {string} selector A jQuery selector. |
| 177 | * @param {array|object} views The subviews for the main view. |
| 178 | * @param {} options |
| 179 | * |
| 180 | * @return |
| 181 | */ |
164 | | |
165 | | // ### Stop tracking subviews |
166 | | // |
167 | | // Stops tracking `views` registered to a `selector`. If no `views` are |
168 | | // set, then all of the `selector`'s subviews will be unregistered and |
169 | | // removed. |
170 | | // |
171 | | // Accepts an `options` object. If `options.silent` is set, `remove` |
172 | | // will *not* be triggered on the unregistered views. |
| 191 | /** |
| 192 | * Stop tracking subviews |
| 193 | * |
| 194 | * Stops tracking `views` registered to a `selector`. If no `views` are |
| 195 | * set, then all of the `selector`'s subviews will be unregistered and |
| 196 | * removed. |
| 197 | * |
| 198 | * Accepts an `options` object. If `options.silent` is set, `remove` |
| 199 | * will *not* be triggered on the unregistered views. |
| 200 | * |
| 201 | * @param {string} selector A jQuery selector. |
| 202 | * @param {array|object} views The subviews for the main view. |
| 203 | * @param {} options |
| 204 | * |
| 205 | * @return |
| 206 | */ |
221 | | |
222 | | // ### Remove all subviews |
223 | | // |
224 | | // Triggers the `remove()` method on all subviews. Detaches the master |
225 | | // view from its parent. Resets the internals of the views manager. |
226 | | // |
227 | | // Accepts an `options` object. If `options.silent` is set, `unset` |
228 | | // will *not* be triggered on the master view's parent. |
| 261 | /** |
| 262 | * Remove all subviews |
| 263 | * |
| 264 | * Triggers the `remove()` method on all subviews. Detaches the master |
| 265 | * view from its parent. Resets the internals of the views manager. |
| 266 | * |
| 267 | * Accepts an `options` object. If `options.silent` is set, `unset` |
| 268 | * will *not* be triggered on the master view's parent. |
| 269 | * |
| 270 | * @param {} options |
| 271 | * |
| 272 | * @return {} |
| 273 | */ |
251 | | |
252 | | // ### Insert subviews into a selector |
253 | | // |
254 | | // By default, appends the subview `els` to the end of the `$target` |
255 | | // selector. If `options.at` is set, inserts the subview `els` at the |
256 | | // provided index. |
257 | | // |
258 | | // Can be overridden in subclasses. |
| 302 | /** |
| 303 | * Insert subviews into a selector |
| 304 | * |
| 305 | * By default, appends the subview `els` to the end of the `$target` |
| 306 | * selector. If `options.at` is set, inserts the subview `els` at the |
| 307 | * provided index. |
| 308 | * |
| 309 | * Can be overridden in subclasses. |
| 310 | * |
| 311 | * @param {} target |
| 312 | * @param {} els |
| 313 | * @param {} options |
| 314 | * |
| 315 | * @return |
| 316 | */ |
286 | | |
287 | | // #### Internal. Attaches a series of views to a selector. |
288 | | // |
289 | | // Checks to see if a matching selector exists, renders the views, |
290 | | // performs the proper DOM operation, and then checks if the view is |
291 | | // attached to the document. |
| 344 | /** |
| 345 | * Internal. Attaches a series of views to a selector. |
| 346 | * |
| 347 | * Checks to see if a matching selector exists, renders the views, |
| 348 | * performs the proper DOM operation, and then checks if the view is |
| 349 | * attached to the document. |
| 350 | * |
| 351 | * @param {string} selector A jQuery selector. |
| 352 | * @param {array|object} views The subviews for the main view. |
| 353 | * @param {} options |
| 354 | * |
| 355 | * @return |
| 356 | */ |