Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll have to overcome the old-school way of doing it :) Meteor is a lot simpler than you think. <strong>A good rule of thumb is that if you're using jQuery to manipulate any DOM elements, you're probably doing it wrong.</strong> Additionally, if you're accessing any data without using the collection API, you'd better have good reason to do so.</p> <p>In your case, you don't need to code up any manual dependencies at all. Manual dependencies are rarely needed in most Meteor applications.</p> <p>The first thing you need to do is put all your tenants inside a <code>Meteor.Collection</code>, which will make them easier to work with. </p> <pre><code>Tenants = new Meteor.Collection("tenants"); </code></pre> <p>Your <code>tenantsBlock</code> template should look something like this (modulo some different html elements):</p> <pre><code>&lt;template name="tenantsBlock"&gt; &lt;ol&gt; {{#each tenants}} &lt;li class="name {{selected}}"&gt; &lt;span&gt;Primary Tenant: {{primaryTenant}}&lt;/span&gt; &lt;span&gt;Other Tenants: {{otherTenants}}&lt;/span&gt; &lt;span&gt;Phone Number: {{phoneNumber}}&lt;/span&gt; &lt;span&gt;Email Address: {{emailAddress}}&lt;/span&gt; &lt;span&gt;Added Date: {{addedDate}}&lt;/span&gt; &lt;/li&gt; {{/each}} &lt;/ol&gt; &lt;/template&gt; </code></pre> <p>Each document in <code>Tenants</code> should look something like the following:</p> <pre><code>{ primaryTenant: "Joe Blow", otherTenants: "Mickey Mouse, Minnie Mouse", phoneNumber: "555-234-5623", emailAddress: "joe.blow@foo.com", addedDate: "2005-10-30T10:45Z" } </code></pre> <p>Then, all the code you would need is just for the selection/deselection, and you can delete everything else:</p> <pre class="lang-js prettyprint-override"><code>Template.tenantsBlock.tenants = function() { return Tenants.find(); }; Template.tenantsBlock.selected = function() { return Session.equals("selectedTenant", this._id); }; Template.tenantsBlock.events({ 'click .name': function(e) { Session.set("selectedTenant", this._id); } }); </code></pre> <p>Once again, I reiterate that you should never be doing DOM manipulations with Javascript when using Meteor. You just update your data and your templates will reactively update if everything is done correctly. Declare <strong>how</strong> you want your data to look, then change the data and watch the magic.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload