From e22e40d90f0f9b7edca089ec38109223c1008504 Mon Sep 17 00:00:00 2001 From: davetayls Date: Wed, 28 Jan 2015 09:47:38 +0000 Subject: [PATCH 1/2] add triggers to Marionette.View --- marionette/marionette.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 397da6fab..40c0f6775 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -261,7 +261,7 @@ declare module Marionette { * Regions that are attached to the document when you execute show are * special in that the views that they show will also become attached * to the document. These regions fire a pair of triggerMethods on all - * of the views that are about to be attached – even the nested ones. + * of the views that are about to be attached � even the nested ones. * This can cause a performance issue if you're rendering hundreds or * thousands of views at once. * If you think these events might be causing some lag in your app, you @@ -274,7 +274,7 @@ declare module Marionette { * Regions that are attached to the document when you execute show are * special in that the views that they show will also become attached * to the document. These regions fire a pair of triggerMethods on all - * of the views that are about to be attached – even the nested ones. + * of the views that are about to be attached � even the nested ones. * This can cause a performance issue if you're rendering hundreds or * thousands of views at once. * If you think these events might be causing some lag in your app, you @@ -677,6 +677,12 @@ declare module Marionette { */ behaviors: any; + /** + * Defines `triggers` to forward DOM events to view + * events. `triggers: {"click .foo": "do:foo"}` + */ + triggers:{[key:string]:any}; + /** * A configuration hash for models. The left side is the event on * the model, and the right side is the name of the From ead784855cd4c2803d894d05d2583723b2a4dfa3 Mon Sep 17 00:00:00 2001 From: davetayls Date: Wed, 28 Jan 2015 09:51:42 +0000 Subject: [PATCH 2/2] added triggers test to Marionette.View --- marionette/marionette-tests.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/marionette/marionette-tests.ts b/marionette/marionette-tests.ts index eec2db8a4..c75837810 100644 --- a/marionette/marionette-tests.ts +++ b/marionette/marionette-tests.ts @@ -92,6 +92,17 @@ module Marionette.Tests { } } + class MyBaseView extends Marionette.View { + + constructor() { + super(); + this.triggers = { + 'click .foo': 'bar' + }; + } + + } + class MyView extends Marionette.ItemView { behaviors: any; @@ -298,4 +309,4 @@ module Marionette.Tests { }); } -} \ No newline at end of file +}