meteor

Meteor js custom pagination

微笑、不失礼 提交于 2020-01-04 18:56:59
问题 I kindly need a support. I have written a pagination following a YouTube tutorial, which works fine with the exception of when going backwards again. It has only 2 buttons, previous and next , when the next button is clicked it works fine but the previous button only go backwards once. Let's say I have 20 records in the collections paginated to display 5 at a time, the next button could go to the end to the fourth page but the previous button would not go pass one step backwards. Please what

Meteor - Wrapping NPMs with Meteor.wrapAsync()

余生颓废 提交于 2020-01-04 14:17:22
问题 I'm trying to wrap the superagent NPM with Meteor.wrapAsync, everything works fine until the last line of the code below, which causes my meteor app to crash. var superagent = Meteor.npmRequire('superagent'); // Example of how superagent works superagent.get('http://127.0.0.1:8080/json/', function(result){ console.log(result); // Works, shows the result }); // This appears to work too var agentAsync = Meteor.wrapAsync(superagent.get); // This crashes app agentAsync('http://127.0.0.1:8080/json

Specify what version of Meteor to use locally

大城市里の小女人 提交于 2020-01-04 13:43:20
问题 So I'm just having a look at someone's code and downloaded it to try and run locally. The problem is that they last updated the project in April so they're not using the latest version of meteor but my localhost is trying to do just that. I read there was a way to specify what version of Meteor would run locally (and subsequently package) but I can't find it again for some reason. 回答1: To set the version for the current project only, write the number in .meteor/release text file. 回答2: meteor

Meteor - rendering template with a document from a Collection

╄→гoц情女王★ 提交于 2020-01-04 13:37:58
问题 Basically, I'm just trying to render a template with the result attribute of a document returned by a MongoDB find() call. I have autosubscribe on. I have an html template <template name="results"> status: {{result}} </template> And I'm trying to render it in the js file: if (Meteor.is_client) { Template.results.result = function() { return Results.find({'type': 'test'}).fetch()[0].result; } } There's a record in mongo {type: "test", result: "success"} . The code keeps throwing an error that

Meteor template not updating using click event

旧城冷巷雨未停 提交于 2020-01-04 11:57:05
问题 I'm trying to make a reactive menu using meteor session (to persist the view the user was).. but it is not working, the Session.get('currentView') get changed (teste in chrome console), but the page don't render again. .html <div class="col-1-1 menu" style="height: 42px;"> <ul> <li><a class="dashButton" href="#"># Dashboard</a></li> <li><a class="myJobsButton"href="#">Jobs</a></li> <li><a class="helpPageButton"href="#">Help</a></li> </ul> <br style="clear:left"/> </div> {{#if currentViewIs

meteor, mongodb, spacebars, how do I display only 2 decimal places

感情迁移 提交于 2020-01-04 08:09:51
问题 I have a collection that has values like { "pctFail" : "0.3515500159795462" } and when I pass this to a template and display as {{myTemplate}}% it displays in my html as 0.3515500159795462%. How do I display this as 0.35% ? 回答1: You could override the data context's property with a template helper method: Template.myTemplate.helpers({ pctFail: function () { return this.pctFail.toFixed(2); } }) And then use {{pctFail}}% as before. If you insist on storing the numerical property as a string,

Get React to display individual error messages under form input field

一曲冷凌霜 提交于 2020-01-04 05:26:11
问题 I'm submitting a form that returns an array of errors and I'm having trouble figuring out how to get each individual error to appear under the correct input field. Right now all the errors print under each input field. I'm using react-bootstrap . Any help would be appreciated. getValidationState() { var errors = this.state.errors; if (!$.isEmptyObject(errors)) { errors.forEach(function(error) { console.log("error:", error.name); }); } } render() { const inputProps = { value: this.state

MongoDB: How to Sort a Query Before Updating

南笙酒味 提交于 2020-01-04 05:18:14
问题 I'm writing a Meteor (Node.js) app which uses MongoDB on the backend. At a certain point in my code, I need to update a specific document within a collection. I need to use Mongo's update() method, but I'm having trouble passing in the proper (complex) query to narrow down to that one, specific document. The document I'm trying to update is: db.collection.find({market: 'AAA'}).sort({creationDate:-1}).limit(1) In words, the one document in collection that has a market of AAA and was created

MongoDB: How to Sort a Query Before Updating

喜你入骨 提交于 2020-01-04 05:18:04
问题 I'm writing a Meteor (Node.js) app which uses MongoDB on the backend. At a certain point in my code, I need to update a specific document within a collection. I need to use Mongo's update() method, but I'm having trouble passing in the proper (complex) query to narrow down to that one, specific document. The document I'm trying to update is: db.collection.find({market: 'AAA'}).sort({creationDate:-1}).limit(1) In words, the one document in collection that has a market of AAA and was created

Two ways to define helpers in Meteor

馋奶兔 提交于 2020-01-04 05:15:36
问题 EDIT: This is no longer relevant in Meteor 1.0. The first syntax has been deprecated, and only the second is supported. It seems that there are two ways to define what are apparently called helpers in Meteor: Template.foo.helper1 = function() { ... } Other way: Template.foo.helpers({ helper2: function() { ... } }); Is there any semantic or usage difference between the two? The only restriction I can see is that the first usage can't use reserved keywords. I'm wondering if the distinction