diff --git a/types/backbone.marionette/backbone.marionette-tests.ts b/types/backbone.marionette/backbone.marionette-tests.ts index f57e9e2edc..c6400b2672 100644 --- a/types/backbone.marionette/backbone.marionette-tests.ts +++ b/types/backbone.marionette/backbone.marionette-tests.ts @@ -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 = v.delegateEntityEvents(); + const uiHandle: JQuery = v.getUI('destroy'); } function CollectionViewTests() { diff --git a/types/backbone.marionette/index.d.ts b/types/backbone.marionette/index.d.ts index 7626d60d56..0b717c9bb1 100644 --- a/types/backbone.marionette/index.d.ts +++ b/types/backbone.marionette/index.d.ts @@ -1143,6 +1143,11 @@ export class View extends Backbone.View 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. */