antonmedv/monkberry

Simples examples folder

minimok opened this issue · 3 comments

Monkberry is very nice indeed! Would be really cool to see some "simple" examples of how to use events - e.g.
I have an object 'Fruit' that has a name property and 1 method 'handleClick' which, say, logs to console every time it's invoked.

I pass a Fruit instance new Fruit() to view.update(..)

<h1>{{name}}</h1>

<button onClick="{{handleClick}}">ClickMe</button>

The name of my fruit shows up perfectly. But, I'm not getting anything happening when I try and call its handleClick method...a simple example would probably illustrate how to do this in 5 secs.

Cheers for any pointers...

@minimok try event handling examples from docs.

Thanks. I forgot to mention I've read the docs. None of them illustrate passing an object into the DOM and then using DOM events to execute methods belonging to the specific object that was passed in (aka OOP). I've written a brutal hack to solve the issue - basically removing all event-handling from monkberry's role in the app and using it purely to render data...which it's very good at.

There a few solution: dom delegating/event directives/direct event listeners. Read more at docs: http://monkberry.js.org/docs/event-handling