FAQ Database Discussion Community


Meteor Counts in Router Level Subscription

javascript,mongodb,meteor,publish-subscribe,meteor-blaze
I have a list that subscribes to posts publication with a limit. Publication Meteor.publish('posts', function(options) { check(options, { sort: Object, limit: Number }); var posts = Posts.find({}, options); return posts; }); within the list, I have items under each list.html {{#each posts}} {{> postItem}} {{/each}} within each postItem, I would...

How to pull the data context from a view in Meteor using Blaze.getData()

javascript,meteor,meteor-blaze,spacebars
I have a select input in one of my Meteor templates which has three pieces of data associated with each select option. I am trying to send all three pieces of data (as an object) to a new template that is rendered via the Blaze API on the 'change' event...

MeteorJS: Selectively load javascript of each template

javascript,node.js,meteor,meteor-blaze
I have notice that meteor is creating and loading every template javascript file. Is it possible to selectively load javascript of each template? Because my app generate template file for each of my user. So if this is the case every user's template javascript is loaded to the page. That...

get autoform non-collection forms method return value

javascript,node.js,meteor,meteor-blaze,meteor-autoform
I want to use meteor-autoform for my non-collection forms. I try this approach but I want to get method return value and display it on client. Please guide me how to do this. This is my schema (common.js): Schema = {}; Schema.echoSchema = new SimpleSchema({ echoText: { type: String, label:...

Rendering static HTML in Meteor/Blaze

meteor,meteor-blaze,spacebars
I have been trying to include static HTML+JavaScript inside the Meteor / Telescope (telesc.pe) application, and have not been able to get things working with Blaze. To create a simpler case than my original, I have tried inserting a simple HTML + javascript code block (very basic D3.js visualization that...

What is global object UI in meteor framework and how should it be utilised?

javascript,meteor,meteor-blaze
A console.log(UI) will produce the following result Object {_DOMBackend: Object, _EventSupport: Object, _throwNextException: false, currentView: null, _globalHelpers: Object…} It seems there is a lack of documentation out there, would someone kindly share more information on this? Thanks in advance. ...

MeteorJS and Mongo: Initial collection count is always 0

javascript,mongodb,web,meteor,meteor-blaze
I have a self project of creating sudoku grid using meteor js. In this code, i try to fill in the database first before initialising the template and the template will just read from the database for existing values. below is my code for client side js: Cells = new...

Meteor ReactiveVar doesnt works with Meteor.call in event

meteor,meteor-blaze,meteor-helper
I am using ReactiveVar. onCreated I set ReactiveVar with Meteor.Call. When I try to change my reactive variables from event, I am getting Exception in delivering result of invoking 'namelist' Hope my code below will explain my problem more. Template: <template name="Name"> {{#each list}} Name : {{name}} Age : {{age}}...

Meteor content not displaying

javascript,meteor,meteor-blaze
I am having issues with either Flow Router or my template level subscriptions but the data is not being rendered on the page. Just incase the issue isn't what I have pasted here I have included a link to the entire github repo: https://github.com/adjohnston/checkr-meteor lib/routes.js listRoutes.route('/:slug', { name: 'list', subscriptions:...

Scroll to the bottom in Meteorjs

javascript,jquery,meteor,meteor-blaze
I have a list template that looks like: {{#each item}} {{ this }} {{/each}} The item in that helper is a database cursor that looks like this: Items.find({ group: Session('group') }); So as the group changes the template re-renders. I want the template to be scrolled to the bottom every...

Meteor template Blaze how to return only first element of array

templates,meteor,meteor-blaze
For example I have an array: var arr = ['a', 'b'] and want to get only first element in template

Create/modify Meteor templates at runtime

meteor,meteor-blaze
I am wondering how to solve this problem: I have a template which contains some text with some template helpers inside: <template>Hello {{who}}, the wheather is {{weather}}</template> Now I need to change the content of the template dynamically at runtime, while maintaining the helper functionality. For example I would need...

Get jQuery Element from currentView

meteor,meteor-blaze
In the api docs, the current template instance view can be found using selectors given that the selector's attribute is known ahead of time. template.findAll(selector) template.$(selector) I also know that it is possible to get the view from Blaze.currentView or template.view, but is it possible to get the jQuery element...

Are triple brackets XSS safe in Meteor?

meteor,handlebars.js,meteor-blaze
I wonder if triple curly brackets sanitize user input within templates to be XSS safe. <script> tags won't render out, but how about other creepy XSS hacks? Thanks in advance!...

Meteor #each loop ready

javascript,meteor,meteor-blaze
I wonder is there any way to know if #each loop is "ready". By "ready" I mean it rendered all nodes and inserted into the DOM. I don't even speak about onRendered callback (old rendered). I tried <template name="myTemplate"> <div class="some-class"> {{#if Template.subscriptionsReady}} {{#each messages}} <div>{{text}}</div> {{/each}} <script> $(".some-class").trigger("LOOP_READY") </script>...

Meteor Template.registerHelper() not working within {{#if}} block

meteor,meteor-blaze,meteor-helper
Defined 3 global helpers in Meteor as follows: Template.registerHelper('activeTrips', function () { console.log("Global Active Trips"); return Trips.find().count(); }); Template.registerHelper('isSuperUser', function () { console.log("Global isSuperUser"); return Meteor.user().username === "superuser"; }); Template.registerHelpr('isAdminUser', function () { console.log("Global isAdmin"); return Roles.userIsInRole(Meteor.user(), ['admin']); }); Used as template count displays {{activeTrips}} displays count correctly! But other...

Compare template helper values in Spacebars {{#if}} block

javascript,templates,meteor,meteor-blaze,spacebars
I need to compare two template helper values that are located in nested templates. I was wondering if there is an easy way to compare two template helpers (one from the parent template) in an {{#if}} statement like so: {{#each bids}} {{#if bid.price===../job.price}} <span>some text</span> {{else}} <span>some other text</span> {{/if}}...

What is the difference between Template.created and Template.onCreated in Meteor?

javascript,templates,meteor,meteor-blaze
Template.templatename.onCreated is mentioned in the documentation (along with the .onRendered and .onDestroyed methods). But when I call these nothing happens. If i call Template.templatename.created for instance, this works. Any idea whats going on? Am I misreading something in the docs? is this a reference to something else ? EDIT :...

MeteorJS Blaze.getData() occasionally returns undefined

meteor,meteor-blaze
I'm currently rendering bootstrap modals on my webpage using MeteorJS's "renderWithData" method to load each template when it's needed. I'm running into an issue where my helper methods which access the data in the modal using "Blaze.getData()" will occasionally return undefined and I'm unsure how to fix that. The only...

MeteorJS: Input value in a table is displayed twice

javascript,html,web,meteor,meteor-blaze
I have this issue with MeteorJS with regards to inserting value to an editable table. Whenever I insert a value and the blur event handler is called (doing an update operation to db), the value in the table cell is displayed twice. I have the code available at: https://github.com/jeffrey-effendy/sudolver Thanks...

Confusion about Meteor _uihooks and what triggers them

meteor,meteor-blaze
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...

How to add menus/ subtopics for meteor site?

javascript,node.js,meteor,routing,meteor-blaze
I am new to meteor. I followed the tutorials and successfully making simple interfaces like below. I tried finding examples to add menus/ subtopics like this which does not reload the page when clicked, but I couldn't find any examples. Could you please give me an example how to do...

Turning off Reactivity during field edit

meteor,meteor-blaze
I have a reactive form I am working on, and need to solve a problem. The problem is that my users are using tablets/cellphones over slower cell connections, and sometimes loose connection. When the connection is re-established, Meteor will fire off all the DDP messages, thus triggering Reactivity in the...

Detecting if template was re-rendered due to data context change

meteor,meteor-blaze,autorun
Here's a pretty common pattern: Template.myTemplate.rendered = function () { this.autorun(function () { var selector = {}; // should depend on the current data context MyCollection.find(selector).observe({ // ... }); }); } In general, I want the selector value depend on the current data context, which may potentially change, but we...

Use UI or Template for helpers

meteor,meteor-blaze,meteor-helper
I'm just learning Meteor and I've defined a few helpers that I use in my templates. I've noticed that I can do this in two different ways, but which solution is considered best practice? And why? Solution 1 UI.registerHelper('firstChar', function (name) { return name.charAt(0); }); Solution 2 Template.registerHelper('firstChar', function (name)...

How can I set the data into a template dynamically?

meteor,meteor-blaze
I have a list of Task objects. I have a template which contains a modal form to edit a task. When a user clicks the link to a single Task I want to set the task to be edited to the Task that was clicked and then render the form....

Customizing LoginButtons in meteor

javascript,meteor,meteorite,meteor-blaze,meteor-accounts
I am building a Login page in meteor. It has a facebook login button, gmail login button and linkedin login button. Then I have a Meteor's default login form. Everything is fine so far. The only challenge is, I need to put all these social networking login buttons below my...

Meteor Helper Check equality

javascript,meteor,meteor-blaze,spacebars
Is there a way to check the value of a string in meteor helper? Lets say i have this helper Template.example.helpers({ typeOfVideo:function(videoType){ var videoLink = GS.Gems.Collections.Gems.findOne({_id:this._id}).videoLink; if(videoLink.match(/youtube\.com/)){ return "youtube"; }else if(videoLink.match(/vimeo\.com/)){ return "vimeo"; }else{ return "undefined" } } }) Now i want to check if the video is equal to...

Is there any way to show the current saved state with meteor.js autoform package?

javascript,meteor,meteor-blaze,meteor-autoform
I'm using meteor.js with the aldeed:autoform package with its autosave feature and I'm trying to think of a way to show when the form is saving and when all the data has been saved.

Meteor template: What's the simplest way to check if a user is logged in?

meteor,meteor-blaze,meteor-accounts,meteor-helper
I'm using Meteor's accounts-ui. Is there a way to check if the user is logged in on the template without writing custom helper code? Pseudo code: {{#if userIsLoggedIn }} You're logged in {{/if}} If not, what's the cleanest, most idiomatic way of doing it? I only care about client-side here....

event.target is undefined in events

javascript,meteor,handlebars.js,meteor-blaze,meteor-helper
How to use each input values in events? Hope my below code will explain you well. HTML: <template name="UpdateAge"> {{#each Name}} <div data-action="showPrompt"> <div> Some content </div> <div> <div> Some content </div> </div> <div> Name : {{name}} Age : <input type="text" name="age" value="{{age}}"/> //I need to access age values in...

Meteor blaze each inside each

meteor,meteor-blaze
I've been trying to use blaze Each with a Each inside ColA being one collection ColB another different collection (not inside ColA) {{#each colA}} {{#each colB}} {{this}} // refer the outer Loop? {{/each}} {{/each}} like this guy asked on this Stack Post but when i try that the app brokes....

Convert ng-click to Blaze in meteoric

angularjs,meteor,ionic-framework,meteor-blaze,meteoric
I used ng-click as below in ionic: <div class="list"> <a class="item item-icon-right nav-clear" href="#/app/list1" ng-click="closeMenu()"> <i class="icon ion-ios7-paper"></i> Item 1 </a> .... </div> know I want to use Meteor with Meteoric. I don't know how to convert ng-click to Blaze version. Please guide me. I didn't find anything about this...

Meteor: Access Template Helper (or variable) from another helper

meteor,meteor-blaze,spacebars,meteor-helper
How can I reference a template helper from another one? For example... Template.XXX.helpers({ reusableHelper: function() { return this.field1 * 25 / 100; //or some other result }, anotherHelper: function() { if (this.reusableHelper() > 300) //this does not work return this.reusableHelper() + ' is greater than 300'; else return this.reusableHelper() +...