Merge pull request #26100 from Schlaefer/feature/backboneMarionette-addGetUI

[backbone.marionette] adds View.getUI() and Behavior.getUI()
This commit is contained in:
Armando Aguirre
2018-06-05 18:04:47 -07:00
committed by GitHub
2 changed files with 21 additions and 0 deletions
@@ -1,3 +1,4 @@
import * as JQuery from 'jquery';
import * as Marionette from 'backbone.marionette';
import * as Backbone from 'backbone';
@@ -9,6 +10,10 @@ class DestroyWarn extends Marionette.Behavior {
message: 'you are destroying!'
};
ui = {
destroy: '.foo'
};
// behaviors have events that are bound to the views DOM
events = {
'click @ui.destroy': 'warnBeforeDestroy'
@@ -258,12 +263,18 @@ function RegionTests() {
});
}
function BehaviorTest() {
const b = new DestroyWarn();
const uiHandle: JQuery = b.getUI('destroy');
}
function ViewTests() {
const v = new MyView(new MyModel());
const isDestroyed: boolean = v.isDestroyed();
const isRendered: boolean = v.isRendered();
const isAttached: boolean = v.isAttached();
const vv: Marionette.View<Backbone.Model> = v.delegateEntityEvents();
const uiHandle: JQuery = v.getUI('destroy');
}
function CollectionViewTests() {
+10
View File
@@ -1143,6 +1143,11 @@ export class View<TModel extends Backbone.Model> extends Backbone.View<TModel> i
* throughout the view with the ui attribute.
*/
ui: any;
/**
* Get handle on UI element defined in ui hash
*/
getUI(ui: string): JQuery;
}
export interface CollectionViewOptions<
@@ -1561,6 +1566,11 @@ export class Behavior extends Object {
*/
ui: any;
/**
* Get handle on UI element defined in ui hash
*/
getUI(ui: string): JQuery;
/**
* Any triggers you define on the Behavior will be triggered in response to the appropriate event on the view.
*/