petermichaux / maria

The MVC framework for JavaScript applications. The real MVC. The Smalltalk MVC. The Gang of Four MVC.
BSD 2-Clause "Simplified" License
764 stars 51 forks source link

No way to get bubbling behavior for blur events using Maria and Firefox #63

Closed VincentToups closed 11 years ago

VincentToups commented 11 years ago

blur events do not bubble, and all browsers apart from Firefox implement the focusout event, which is has this property. In Firefox, one can simulate the this behavior by calling addEventHandler with an optional argument, useCapture to true. However, when declaring uiActions in Maria, there is no way to express the intent to set useCapture to true, so focusout behavior is inaccessible.

One can override the buildUIActions method but a complete implementation involves deep modification of code all the way down into evento.on. It isn't clear what the ramifications of such a modification are.

Perhaps an alternative for maria is to specify an array of the form ["selector" ,useCapture] as the key in uiActions and then having Maria set the correct useCapture value.

petermichaux commented 11 years ago

Why can you not add your blur listener to the DOM element of interest?

VincentToups commented 11 years ago

This is a possible work around, but it breaks the uniformity of the code somewhat. Given that maria provides a single place to describe all event dispatching, it would be nice if we could describe all possible event dispatching descriptions in one place.

petermichaux commented 11 years ago

You can add blur listeners to events that are in the template. Based on your other ticket, I think you may have a design that is fighting against the Maria way of doing things. Your element that you want to watch for blur is not in the template. I would likely make another view called app.EditorView that has the <input> in the template and then instantiate one of these views when I need it.

petermichaux commented 11 years ago

If you want to have the <input> in the same template as the <div> you can do it like I did in TodoMVC...

https://github.com/tastejs/todomvc/blob/gh-pages/architecture-examples/maria/js/views/TodoView.js#L10

https://github.com/tastejs/todomvc/blob/gh-pages/architecture-examples/maria/js/templates/TodoTemplate.js#L18

VincentToups commented 11 years ago

You may be right about developing against the maria grain - I'll try both approaches you described.

On Mon, Jul 22, 2013 at 5:31 PM, Peter Michaux notifications@github.comwrote:

If you want to have the in the same template as the

you can do it like I did in TodoMVC...

https://github.com/tastejs/todomvc/blob/gh-pages/architecture-examples/maria/js/views/TodoView.js#L10

— Reply to this email directly or view it on GitHubhttps://github.com/petermichaux/maria/issues/63#issuecomment-21352263 .

petermichaux commented 11 years ago

Please reopen if you have more to discuss.