meteor-blaze

Is there any way to insert a callback before/after a templates context is updated?

我只是一个虾纸丫 提交于 2019-12-11 19:06:19
问题 I'm aware of Template.onRendered, however I have the need to destroy and setup some plugins that act on the dom when the actual context is updated. So saying I have content template, I'd need something similar to the following: Template.content.onBeforeChange(function () { $(".editor").editable("destroy"); }); Template.content.onAfterChange(function () { $(".editor").editable(); }); Is there any current way I can achieve this with the existing Template api? 回答1: You should be able to detect a

leaflet latlng to name of location

瘦欲@ 提交于 2019-12-11 15:46:10
问题 I'm creating a form where the location is being passed to an input element by default. (Basically, click on the map and the coords are default on the form) While I need to work with the coords, and I have no problem returning the coordinates, I want to show the name of the city/area of those coords in the form instead of the lat/lng. <input type="text" id="coords_lat" name="loc_lat" value={{clickedLat}} disabled> <input type="text" id="coords_lng" name="loc_lng" value={{clickedLng}} disabled>

Access nested objects

会有一股神秘感。 提交于 2019-12-11 13:32:08
问题 I'm trying to access the nested ingredients object within the main entry. The output from the {{recipe.ingredients}} tag is [object Object],[object Object] . What do I need to put in order for the {{recipe.ingredients}} to output the name and amount? Object from a database { "_id": "zSetYKmvv2HB6v8hJ", "name": "Grilled Cheese", "desc": "Sandwich", "ingredients": [{ "name": "Bread", "amount": "2 Slices" }, { "name": "Cheese", "amount": "Lots" }], "author": "ttpbGPgzDnqwN8Gg7", "createdAt":

Meteor recursive template doesn't work

[亡魂溺海] 提交于 2019-12-11 12:44:22
问题 I tried to have a recursive template like this: <template name="generate"> {{#if elements}} {{#each elements}} <div>{{#if elements}}{{> generate}}{{/if}}</div> {{/each}} {{else}} {{> generate elements=getElements}} {{/if}} </template> with the helper: Template.generate.helpers({ getElements: function() { return Elements.find() } }) and the "Elements" data object: [{ _id : "fgQ4GHrrZGFFGWPZQ", elements" : [{ _id : "hY8iAYJC4KBwGKN84", elements : [] }] },{ _id : "rtMNfaQYwqzNTYqoD", elements :

How should I make sure that a reactive DOM element has been loaded?

假如想象 提交于 2019-12-11 08:58:11
问题 I have a template image where I display images. The image display toggles between canvas and img tags, depending on if the user just created the image or if it is already on server. I toogle between img and canvas using a reactive dictionary called pageSession where I store a boolean reactive variable called displayMode . I have an helper currentDisplayMode used to return displayMode value. So the helper looks like this: Template.image.helpers({ "currentDisplayMode" : function(){ return

How to pass an object from to a block helper back to the block in meteor blaze?

让人想犯罪 __ 提交于 2019-12-11 07:17:44
问题 Before Meteor 0.8, that brought blaze, I was able to pass objects to a custom block helper content like this: return options.fn(object) Now that with blaze, block helpers require to return a template something like this. return Template.someTemplate How can I achieve the old behaviour. What I want to to is the following: I use a blockhelper {{#blockhelper argument="something"}} {{somePartOfTheObject}} {{/blockhelper}} Then in the the blockhelper definition, I want to do some stuff based on

Meteor Dynamic Template not working

浪子不回头ぞ 提交于 2019-12-11 07:01:18
问题 The line {{> Template.dynamic template=content }} makes my page not load. It actually crashes my browser sometimes. I had it working for a while but something happened and now it does not work anymore. {{> Template.dynamic template='navBar' }} works so my packages should be ok. Meteor: 1.4 Packages: kadira:flow-router, kadira:blaze-layout imports/ui/layouts/mainLayout.html: <template name="mainLayout"> <header> <div class="container"> {{> navBar }} </div> </header> <body> <div class=

AutoForm Update Not Working

混江龙づ霸主 提交于 2019-12-11 06:19:18
问题 I am having some difficulty getting an autoform to save. This is a new issue for me; so I am a little unsure on how to fix it. I have the following form: <template name="TaskItems"> {{#if inspectionMode}} <a href="#" class="inspection btn btn-danger">Close Task <i class="glyphicon glyphicon-minus"></i></a> <table class="table table-striped"> <thead> <tr> <th>Facility Section</th> <th>Title</th> <th>Section</th> <th>Code</th> <th>Pass/Fail</th> </tr> </thead> <tbody> {{#each TaskItem}} <tr>

Publish and subscribe to a single object Meteor js

我的梦境 提交于 2019-12-11 04:15:50
问题 How to publish single objects seems not clear enough to me. Please what's the best way to handle this. This code snippet does not display anything on the view. Helper file singleSchool: function () { if (Meteor.userId()) { let myslug = FlowRouter.getParam('myslug'); var subValues = Meteor.subscribe('SingleSchool', myslug ); if (myslug ) { let Schools = SchoolDb.findOne({slug: myslug}); if (Schools && subValues.ready()) { return Schools; } } } }, Publish file Meteor.publish('SingleSchool',

Meteor: “exception in template helper”

你说的曾经没有我的故事 提交于 2019-12-10 19:04:15
问题 I have a basic post stream running in Meteor that pulls from the Posts collection. The template is feed by the following template helper that reaches into the collection: Template.postStream.helpers({ /* Supplies posts collection to the client * view. */ postsStream: function(){ var loggedUser = Meteor.user(); return Posts.find({ userID: loggedUser._id }); }, }); The helper seems to all work fine and the posts appear as expected. However, I get this vague error in the console and I can't work