meteor

How are 'change' events handled in backbone models?

萝らか妹 提交于 2019-12-30 12:21:11
问题 I'm trying to build a model that dynamically updates Session variables in a Meteor project. I know that plain JSON should not be stored within backbone models, so I have a Special model set up like so: initialize : function () { // Log the changed properties this.on('change', function (model, options) { for ( var i in options.changes) this.display(i); Session.set('NewSpecial', model); }); }, //Attributes defaults: { "Product" : null, "ShortDescription" : null, "Category" : "food", "Price" :

Best way to prevent a template helper to be rerun when it is unnecessary?

怎甘沉沦 提交于 2019-12-30 11:12:22
问题 I'm trying to prevent a template helper to be rerun when it is unnecessary. I made a simple application to illustrate this behavior: Let's say I want to display some items that contain only a title and a description. <template name="Tests"> {{#each items}} {{> TestsItems}} {{/each}} </template> <template name="TestsItems"> <div class="title">{{title}}</div> <div class="description">{{description}}</div> </template> I have autopublish enabled. Template.Tests.helpers({ items: function () {

Nested Templates, Finding Parent

瘦欲@ 提交于 2019-12-30 10:53:50
问题 I have a series of nested objects. Say like... stores and items. I have perhaps 10 stores, each with the same 10 items, displayed on the screen at the same time. <template name='store'> {{#each items}} {{> item}} {{/each}} </template> <template name='item'> {{name}} {{qty}} </template> The main problem I have is trying to determine {{qty}} using a helper function. This is because the item inherently does not have a 'quantity', but rather it depends on which "store" it is related to. So I'd

Meteor Iron-Router Without Layout Template or JSON View

筅森魡賤 提交于 2019-12-30 10:33:17
问题 Using Meteor Iron-Router how can I either render data as JSON or simply display it "raw" (without a layout template) Essentially I want to be able to do something like: this.route('rawdata', { path: '/raw/:collection', layoutTemplate: 'nolayout', template: 'raw' }) where /raw/posts would display the raw json of Posts (the collection). Thanks! Notes : I'm aware of JSON endpoint in Meteor But meteor-router is discontinued and Iron-Router does not appear to have a JSON-end-point feature. I also

How do I obtain the path of a file in a Meteor package?

删除回忆录丶 提交于 2019-12-30 10:05:08
问题 I know how to get the current directory from a Meteor package, but how do I get the path of a specific file in the project? node's __dirname and __filename don't work in Meteor. 回答1: It is complicated. meteor run copies your project files to a tree of directories inside <project-dir>/.meteor/local/build , reorganizes them in non-obvious ways (e.g.. the private subdirectory in the original tree becomes the assets subdirectory) and mixes it in with various npm modules to create a bundle that

How do I obtain the path of a file in a Meteor package?

蓝咒 提交于 2019-12-30 10:04:07
问题 I know how to get the current directory from a Meteor package, but how do I get the path of a specific file in the project? node's __dirname and __filename don't work in Meteor. 回答1: It is complicated. meteor run copies your project files to a tree of directories inside <project-dir>/.meteor/local/build , reorganizes them in non-obvious ways (e.g.. the private subdirectory in the original tree becomes the assets subdirectory) and mixes it in with various npm modules to create a bundle that

Meteor display array inside a collection

巧了我就是萌 提交于 2019-12-30 09:35:56
问题 I want create a posts model, with tags, and be able to display all tags for each post. You know a best way to do it ?? I tried this <template name='postsLists'> {{#each post}} {{> postDetails }} {{/each}} </template> <template name='postDetails'> title: {{title}} {{#each tag}} {{tag}} {{/each}} </template> 回答1: You need to use this keyword to get value from an array: <template name='postDetails'> title: {{title}} {{#each tag}} {{this}} {{/each}} </template> 回答2: This code won't work: {{#each

Confusion about Meteor _uihooks and what triggers them

我的未来我决定 提交于 2019-12-30 07:13:28
问题 I'm confused about how _uihooks works. Check out the below code: home.html <template name="homePage"> <section id="home-page"> <div class="container"> <h1>Thought of the day:</h1> <div id="totd"> <span>{{thought}}</span> </div> </div> </section> </template> home.coffee timer = 0 Template.homePage.rendered = -> this.find('#totd')._uihooks = insertElement: (node, next) -> console.log 'Inserted' removeElement: (node) -> console.log 'Removed' Session.set 'randThought', Random.choice thoughts

Error with 'babel-runtime' while trying to serve a Meteor app

こ雲淡風輕ζ 提交于 2019-12-30 07:13:26
问题 I have recently been getting off the ground with Meteor and React. I followed the tutorial on the Meteor website with no problem. Then I tried creating another project, trying to follow another tutorial (for an older version of Meteor). Somewhere along the line, Meteor started throwing up obscure errors. After trying to start fresh again, I ended up reinstalling Meteor and it stopped complaining. However, I'm getting the same problems, again. Specifically, after creating a brand new project:

Error with 'babel-runtime' while trying to serve a Meteor app

我的未来我决定 提交于 2019-12-30 07:13:25
问题 I have recently been getting off the ground with Meteor and React. I followed the tutorial on the Meteor website with no problem. Then I tried creating another project, trying to follow another tutorial (for an older version of Meteor). Somewhere along the line, Meteor started throwing up obscure errors. After trying to start fresh again, I ended up reinstalling Meteor and it stopped complaining. However, I'm getting the same problems, again. Specifically, after creating a brand new project: