0

I am trying to update my famous.js surfaces' content by using Meteor's Blaze.toHTMLWithData(template, data), like Blaze.toHTMLWithData(Template.roomIlanSpecsTemplate, data), with a custom template in a function creating a famous surface inside a famous view. I want to pass the template in the cursorToArray function depending on the type of document returned to its callbacks. But I cannot have a rendered page on the browser, even there is no error in the console. If I use hardcoded version like having createFn function for each different template and then defininig and cursorToArray fucntion with that function it works.

What can be the thing I miss here?

    cursorToArray = function(cursor, renderablesArray, template, createFn){
    //each callback should decide which createFn to use based on result document, cos each result has a different template so a createFn.
    cursor.observe({
    addedAt: function(document, atIndex, before) {
        renderablesArray.splice(atIndex, 0, createFn(document, template));//createRoomIlanView, createRoomRenterIlanView, createFriendLookupIlanView
    },
    changedAt: function(newDocument, oldDocument, atIndex) {
        renderablesArray[atIndex] = createFn(newDocument, template);
    },
    });
}
cursorToArray(Ilans.find(), ilanViews, Template.roomIlanSpecsTemplate, createIlanView);

portion of the createFn definiton:

function createIlanView(data, template){
        var ilanSpecsSurface = new Surface({
          content: Blaze.toHTMLWithData(template, data), 
          properties: {
            fontSize: "14px"
          }
        });

        return ilanSpecsSurface;
    }
sçuçu
  • 2,960
  • 2
  • 33
  • 60
  • Where are you adding your new `Surface` to the context of `FamousEngine` – talves Jun 21 '15 at 19:10
  • I have edited the tags accordingly. – sçuçu Jun 21 '15 at 19:10
  • actual create... function creates a famo.us `view`. adn adds some branches with `modifiers` and `surfaces` to them. the Surface above is one the surfaces at the tip of these brances stemming from the `view`. – sçuçu Jun 21 '15 at 19:14
  • and this views are used to populate an array and it serves as the sequence of the scrollview I use in the content part of the headerfooterlayout. – sçuçu Jun 21 '15 at 19:25
  • I think te problem is with passing the argument of the `Blaze` function call in the content of the surface. If it is hardcoded as I meant in Q it works; `Blaze.toHTMLWithData(Template.roomIlanSpecsTemplate, data)`. But I want to simplfy it. – sçuçu Jun 21 '15 at 19:28

1 Answers1

0

If it is all about older Famous what about using Reactive Surface from https://stackoverflow.com/a/30445791/2288496

var ReactiveTemplate = famodev.ReactiveTemplate;


var reactive = new ReactiveTemplate({
   template: Template.mytemplate,
   data: Collection.find().fetch(),
   properties: {}
});

A good example how to implement Routing, Subscriptions etc. https://github.com/sayawan/flowwy

Community
  • 1
  • 1
mervasdayi
  • 729
  • 6
  • 16