Code Monkey home page Code Monkey logo

Comments (5)

mitar avatar mitar commented on May 22, 2024

Why do you need access to the template instance, if you can share? I hope that there is no need to access it directly.

I moved @templateInstance to @_componentInternals.templateInstance with 6fee849. To minimize the number of fields components use on the instance to only one, @_componentInternals.

I am sorry that this broke things for you. But that should really be something internal you would not have to access during normal use. So I would like to learn more about your use case. Feel free to access it through @_componentInternals. I will not be moving it away anytime soon anymore.

Also, this should be just a cosmetic change, so everything should be rendering as it was.

from meteor-blaze-components.

mitar avatar mitar commented on May 22, 2024

Please confirm that it works once you start using @_componentInternals instead of @templateInstance.

from meteor-blaze-components.

jirkamelichar avatar jirkamelichar commented on May 22, 2024

Hi, I actually came across this problem myself. Here is what I'm trying to accomplish:

I'm building a set of components, which I can re-use to quickly build "table views" - that is a table with data, pagination component, page-size component, filter field component, etc.

The target use case is something like this:

<template name="MyTableView">
{{> Pagination}}
<table>
  <th>
    <tr>Name</tr>
    <tr>Address</tr>
  </th>
  {{#each data}}
    <tr>
      <td>{{name}}</td>
      <td>{{address}}</td>
    </tr>
  {{/each}}
</table>
{{> PageSize}}
</template>

Where MyTableView is a component with a Mixin, which handles template level subscription and holds the current state (page index, page size, etc.)

Because I'd like to avoid having to pass "bridge variables" to the Pagination and PageSize components, like this:

{{> PageSize pageIndex=pageIndex pageSize=pageSize totalCount=totalCount}}

I want to have the PageSize component access parent template instance variables and read/write to the pageIndex (and other) "table view state variables".

I know that I can now use the @_componentInternals.templateInstance, but maybe there is a better way of "connecting" the components (avoiding global state).

Thank you

from meteor-blaze-components.

kostko avatar kostko commented on May 22, 2024

I want to have the PageSize component access parent template instance variables and read/write to the pageIndex (and other) "table view state variables".

Do you mean something like @componentParent() to get the parent component instance? Then you can access the data context, variables and methods on that component instance.

from meteor-blaze-components.

jirkamelichar avatar jirkamelichar commented on May 22, 2024

Thank you Jernej - that's exactly what I needed. I missed it in the documentation.

from meteor-blaze-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.