Ember - click-through processing out of visibility

I wonder if anyone came up with a better way to handle clicks outside the div when using Ember? I know a jQuery way with a global click handler that should indicate every action for certain cases, but I hope someone came up with a way to declare this inside the Ember view. Also, I tried ol 'to give a div index and use blur, but Ember's actions do not seem to allow this.

+7
source share
2 answers

Thanks for the input. I came back and read the jQuerys .on documentation .on . I did not know that you could skip this event. So I took both comments and combined them with something like this.

 didInsertElement: function() { Ember.run.next(this, 'attachClickHandler'); }, attachClickHandler: function (){ var temp = this; $(window).on("click." + temp.elementId, function (e){ //...event here }); }, detachClickHandler: function (){ $(window).off("click." + this.elementId); }, 

This allows a specific event for each instance of the view that I wanted. Thanks guys!

+7
source

you can find ClickElsewhereMixin useful

just enable mixin on any component and implement onClickElsewhere ()

+1
source

All Articles