0

I am trying to find a practical way of handling events with famous-views in Meteor.

So I've read gadicohen's documentation (famous-views demo) and so far it works. But if I add a layoutTemplate to my iron:router and route to the templates with {{>yield}} then I can only catch the events from the layoutTemplate's JS-file.

Meaning I would have to include all my JS-logic into the layout-JS-file, which seems unpractical.

layout.html:

{{#famousContext id="MainCtx"}}

    {{> yield}}
{{/famousContext}}

layout.js:

Template.layout.events({
    'click': function() {}  // works!!
});

someTemplate.html:

<template name="someTemplate">
    {{#Scrollview align="[0,0.06]" origin="[0,0]"}}
        {{#famousEach items}}
            {{>Surface template="item" size="[undefined, true]" }}
         {{/famousEach}}
    {{/Scrollview}}

<template name="item">
    <div id="{{_id}}" style="height: 100%; width: 100%;>
<template>

someTemplate.js:

Template.someTemplate.events({
    'click': function() {}     // doesn't work
});

I have also tried famousEvents, but without success. With target.on() I don't even know how to address a surface inside a Scrollview.

So what would be the Meteor way to do this?

Thx and regards

user3819370
  • 513
  • 1
  • 6
  • 15

1 Answers1

0

I figured out the error, as the famous-view website states "Events do not propogate ("bubble") up (out of a Surface).", so the right usage would be:

Template.item.events({
    'click': function() {}     // should work!
});
user3819370
  • 513
  • 1
  • 6
  • 15
  • can you share a link to what you're working on? I keep thinking about trying famous again, but still not sure if its usable yet. – dcsan Apr 20 '15 at 18:13
  • Hi there, unfortunately it is a industrial project, so I cannot do that, but I can push a testproject with similar syntax onto github, that is if you're still interested? Right now I am trying to find a way to make famous-views work. Otherwise I would have to do everything in plain famous, inside a Tracker.autorun() for reactivity. This is inconvenient, but I know there are Startups who have done this and apparently it functions, only you cannot use Blaze then, which basically sucks. – user3819370 Apr 25 '15 at 17:52
  • As of now, I have to add that famous views is in my opinion not ready for production. The developer also states this on his website. I can only recommend to anyone to develop directly in javascript but with templates (use content: Blaze.render(...)) like described here: https://www.youtube.com/watch?v=bmd-cXSGQAA and here: https://www.discovermeteor.com/blog/meteor-cordova-famous-the-chill-way-to-build-apps/ – user3819370 Apr 29 '15 at 15:52