petermichaux / maria

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

ui-actions declared on dom elements which are not in a view's template do not seem to fire. #62

Closed VincentToups closed 11 years ago

VincentToups commented 11 years ago

I have a maria template which initially displays data inside a <div>. When the user clicks the div, it's text is extracted, placed into an <input>. The user is meant to edit this input and on onblur convert itself back to a standard <div> element, and also update the model. Suppose the input, when it is created, has html class "value-editing"

If I declare a ui-action like so

"onblur .value-editing" "handleBlur"

And defined a handleBlur on the controller, the event never seems to fire.

Do all html elements which might produce events which maria will handle need to be in the initial template or wired up by hand, or am I making some other sort of mistake?

VincentToups commented 11 years ago

I mean, {"onblur .value-editing":"handleBlur"}, above. Sorry, I am translating from parenscript code.

VincentToups commented 11 years ago

The work around for this is to call this.buildUIActions() after any modification of the view's dom elements. Whether this should be more automatic or not is a matter for Peter to determine, so I will leave the issue open. I could go either way.

petermichaux commented 11 years ago

Do all html elements which might produce events which maria will handle need to be in the initial template...?

Yes. uiActions looks for elements in the initial template. Otherwise they do need to be wired up by hand.

petermichaux commented 11 years ago

Please reopen if you have more to discuss.