w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I delay a reactive Meteor template from updating an HTML template variable, when a Meteor.call() updates the database instantly?
Try to wrap your Meteor.call() inside the setTimeout() itself, like: Template.keno.events({ 'click #start' : function(){ setTimeout(function(){ Meteor.call('process',function(){ //do something. }); }, 20000); } });

Categories : Meteor

Meteor template: Pass a parameter into each sub template, and retrieve it in the sub-template helper
When you use {{> child myParam}}, it's calling the child template and associates myParam as current template data context, meaning that in the template you can reference {{paramName}}. In someOtherHelper you could use this.paramName to retrieve "paramValue". However, when you're using {{#each nodes}}{{> child}}{{/each}}, it means that you pass the content of the current list item (fetched from a LocalCursor or directly an array item) as the template data of child, and you can reference the list item properties using {{field}} in html or this.field in js. What's happening here is when you call {{> child myParam}}, the myParam helper content OVERWRITES the current node item as template data, that's why it's messing your node list. A quick (dirty) trick would be to simply extend t

Categories : Meteor

Use template helpers to make text reactive in a Meteor template
I'm pretty new at Meteor, but I think you need to set up a template helper. Template.below.helpers ({ choice1: function () { return currentchoice1; } }), That makes choice1 reactive. Bob

Categories : Javascript

how to make a meteor template helper re-run/render after another template has rendered?
You need a dependency in the template that you want to rerun. There are few possibilities, depending on what data you want to get. For example, you can set a reactive marker in the content template that will notify renderNav that it's done with drawing. Template.contentWidnow.rendered = function() { ... // Set this on the very end of rendered callback. Session.set('contentWindowRenderMark', '' + new Date().getTime() + Math.floor(Math.random() * 1000000) ); } Template.renderNav.contentData = function() { // You don't have to actually use the mark value, // but you need to obtain it so that the dependency // is registered for this helper. var mark = Session.get('contentWindowRenderMark'); // Get the data you need and prepare for displayin

Categories : Javascript

How Do I Call a Template from Within Another Template's Helper Function When Using Meteor?
Calling the template directly should have worked and the helper is not necessary. I think the handlebars call is sensitive to extra spaces. Try: {{>welcome_email}}

Categories : Javascript

Meteor findOne query returns undefined in one template helper. In other template helpers, same query works well
I believe exactly when a collection is ready won't always be consistent, so if you want to cover all your bases, always code for the case where a collection is not ready. There's a quick-and-dirty way of dealing with collections that aren't ready, and a more sophisticated solution you can find in the todos example. Quick and dirty solution would look like this. currentRound: -> gameStatusrecord = GameStatus.findOne(); if(gameStatusRecord) gameStatusRecord.currentRound This will work. Until the collection is ready, currentRound will return null, and your template will briefly render and probably just show a blank for current round. So not ideal user experience but not a huge deal. For a more sophisticated solution, you can check whether a collection that you have subsc

Categories : Javascript

Hide Meteor.users and other information on client
The first thing I'd do is remove the insecure package. mrt remove insecure After you do that a few things will probably break since you're no longer publishing everything to the client. You'll have to setup publications and subscriptions.

Categories : Meteor

Excel/PivotTable: Is there any way to prevent the cells from moving when I filter information?
I'm going to say "No". Pivot tables are a world to themselves inside of Excel. You may have noticed that if you do something that expands them into surrounding data, they don't shift that data, they just warn you. Similarly, if you have formulas that refer to certain columns in a pivot table, filtering the pivot table as you've done doesn't adjust the cell reference as it does when you add or delete regular columns. I assume this is the type of issue you're seeing. If so, consider using the GetPivotData function, which allows you to refer to pivot table columns. Below I've shown how this could work with a simple table. The GetPivotData formula uses a variable (an added bonus!) in cell F1. In this case it gives you the overall total for fiona: =GETPIVOTDATA("value",$E$4,"name",F1)

Categories : Excel

Why Does Using {{@...}} In a Meteor Template Cause Errors?
Looking at the source (at https://github.com/meteor/meteor/blob/master/packages/handlebars/parse.js): It doesn't look like the {{@ ..}} set of expressions are supported with the Handlebars version packaged with Meteor.

Categories : Javascript

how can I use the same template multiple times on meteor.js
There are two ways in my mind this can be done. As Meteor doesn't require page reloads to update your content. There is nothing to stop you have the row save on completion and then just having a loop which populates the page. Your form becomes something like this: <form id="add_time"> {{#each rows}} {{> row}} {{/each}} {{> row}} <input type="submit" id="submit_hours" value="Save and Add Another"/> <input type="button" id="submit_and_exit" value="Save and Exit"/> </form> <template name="row"> <ul> {{> clientsDD _id}} {{> projectsDD _id}} {{> hoursAndTasks _id}} </ul> </template> This would loop through a rows helper which contains your hours data displaying it for editing along with providing a new empty r

Categories : Mongodb

Meteor: Prevent template from re-rendering
I think that it's not necessary to wait with rendering the new question, since the dialog is opaque anyway, so it won't be a difference to the user. You need only to make sure that the dialog itself will not be rendered. There are three ways to achieve it: Put dialog only in {{#constant}} block. Put dialog and question list to separate {{#isolate}} blocks. Put dialog and list in separate templates. That's the most robust and thus recommended method.

Categories : Javascript

Uppercase "a"'s inside a Meteor template
Do you have any constraints on where the a's are within the template? For example, this is how you'd uppercase all a's within all SPANs in the template: Template.complicated.rendered = function() { this.findAll('span').each(function(idx, element) { $(element).html( $(element).html().replace(/a/g, 'A'); }); };     If you want to traverse all top-level nodes, you can do it like that: Template.complicated.rendered = function() { var node = this.firstNode; while(true) { // manipulate with node // // for example, get all text nodes within in // and replace a's with A's if(node === template.lastNode) return; node = node.nextSibling; } } However, you need to be careful with this method and only replace contents of leaf nodes.

Categories : Meteor

Meteor: Template is displayed although collection is not loaded yet
First off, you may be missing the actual function name for the callback as demonstrated in this post. Meteor.subscribe("myCollection", bar, function onComplete() { Session.set('stuffLoaded', true); }); Which seems to be great practice. I don't usually miss a beat using this method. Secondly, I'm not sure subscriptions inside routes work well? I'd rather do the following: '/myroute': function(bar) { Session.set("myCollectionParam", bar) return 'stuffPage'; } So then the subsciption finally looks like this: Meteor.subscribe("myCollection", Session.get("myCollectionParam"), function onComplete() { Session.set('stuffLoaded', true); }); OR (not sure which works correctly for you, depending on your publish function): Meteor.subscribe("myCollection", {bar: Session.ge

Categories : Javascript

Pulse the template every time it is rendered in Meteor
Here's a simple blink. Animating background color requires additional libraries, see jQuery animate backgroundColor . var pulseNode = function(node) { if(!node.style) return; var prev = node.style['background-color'] || 'rgba(255,0,0,0)'; $(node).css('background-color', 'red'); setTimeout(function() { $(node).css('background-color', prev); }, 1000); }; pulse = function(template) { for(var node = template.firstNode; true; node = node.nextSibling) { pulseNode(node); if(node === template.lastNode) return; } } Now, for each template you want to use this, do Template.asdf.rendered = function() { pulse(this); }

Categories : CSS

Why is 'this' in a Meteor Template onRendered Function undefined?
The this inside a template helper will always points to window object. You can access the data context in Template.rendered() or the event handler function. In the event handlers, it is passed as a second argument as function( event, template ), where the template is the current template object. However I suggest you to use the template instance functions such as find(), findAll(), firstNode(), lastNode() rather than data context. Template.task.rendered = function() { if( !this.window ){ //check that 'this' is not a 'window' object var el = this.find( 'div.text' ); // the div that holds due_date //do something } }

Categories : Meteor

Meteor.js Template does not update after variable assignment
Template.results.series should be a function that returns the series, rather than set directly to the series you want to use. That way, when Meteor runs the function to get the series, it can register what the function depends on, and then re-run the function whenever any of the dependencies change. The easiest way to register a dependency for your information is to use the Session object. So your code would look something like: Template.results.series = function () { return Session.get('resultsSeries'); } Meteor.call('queryshow', query, function (err, res) { // handle the error if it's there // ... // Then set the session variable, which will re-run anything that depends on it. Session.set('resultsSeries', res) }

Categories : Javascript

Events are not being triggered when using Template.myTemplate() in Meteor
Function Template.template() returns plain html string. It doesn't have any Meteor properties enabled. What you need is a DOM element with proper behavior injected. ... var node = Meteor.render(Template.infoWindowContent()); outerElement.appendChild(node); ... I'm not sure how to use DOM node in google maps api, but if it's possible, it should be easy.     Also, use the proper events form, it saves much trouble in the long run: Template.infoWindowContent.events({ ... });

Categories : Google Maps

How Do I Properly Make a Meteor Template Reactive?
It seems to me that you aren't using the templates in they way they were really intended to be. A meteor app starts with the main html markup which can only exist once in your app.. <head> <title>My New Fancy App</title> </head> <body> {{>templateName}} </body> Then you add a template.. <template name="templateName"> {{#each items}} template or relevant html goes here.. {{/each}} </template> Now you need a template helper to give you data for your {{#each items}} block helper.. Template.templateName.helpers({ items: function(){ return Items.find({}) } }); All this gets defined on the client side.. Then you'll need a collection and the collection should be defined on both the client and server. Items = new Meteor.

Categories : Javascript

Meteor - Accounts UI Template Get Reverts to Original Upon CSS Save
This is the hot code file editing feature. When you edit a file i think (not sure) meteor copies over the raw meteor files back into your project. To get passed this you need to copy accounts-ui into a a directory called /packages in your project to override the default meteor package.

Categories : Javascript

Format a date from inside a Handlebars Template in Meteor
The solution is quite simple, and maybe someone will find it useful. In most projects you have a couple of date formats you want to use. So it's a good approach to define your formats with readable names. For this example I took just 'short' and 'long', but you will see, it's very easy to extend. So I created an Object in my Client Script: var DateFormats = { short: "DD MMMM - YYYY", long: "dddd DD.MM.YYYY HH:mm" }; Also, I created a Handlebars Helper "formatDate". Edited: Now you should use UI instead of Handlebars // Deprecated since version 0.8.0 Handlebars.registerHelper("formatDate", function(datetime, format) { // Use UI.registerHelper.. UI.registerHelper("formatDate", function(datetime, format) { if (moment) { // can use other formats like 'lll' too

Categories : Javascript

Meteor template helpers fire multiple times
If you use this template in multiple places, the code will be executed multiple times, that's true. Although, using mongodb cursors calls is safe, Meteor optimizes it and calls identical queries only once (on server) and all calls on client (with minimongo) are cheap.

Categories : Meteor

Joomla component moving div location in template structure
It seems that you put your closing div (gridContainer) in wrong condition which is not actually rendering in case of buy page. Div tag is not balanced in buy page, that's why footer is not sticky and wrapped inside the parent div.

Categories : PHP

Attaching jQuery plugins to Meteor template-generated DOM elements
In the template, wrap the div you want to apply the jQuery with {{#constant}} helper. This will kill all reactivity you may have on elements wrapped up. If you need reactivity or constant did not help, try this hack. I unbind the event of the element when rendered is called and bind it right after. The problem in this case is that rendered is called like a dozen times and it screw up some way I haven't figured out. Try debugging it to see how many it is called with console.log in the first line of rendered. Hope it helps!

Categories : Meteor

Meteor on collection change update Template select element
In your HTML-template, if you surround your select-element with the constant block helper, the part inside the constant block won't be re-rendered. Maybe that would be a solution?

Categories : Meteor

Meteor Template re-renders when Accounts.createUser throws error
1) Check all dependencies for the upper template. Does any of its data depend on createUser result? Double-check all Session variables. 2) Do you have a callback in the createUser call? 3) Try putting your form template within a {{#constant}} block. This should prevent rerendering and losing data. Also, if you use preserveInputs package, remember that input data is preserved only for inputs that have either id or name set.

Categories : Javascript

I want to use Meteor.setInterval() to update a time-template, it doesnt work
The code should be (note no () after uhrzeit): if (Meteor.isClient) { Template.uhr.zeit = function() { Meteor.setInterval(uhrzeit, 1000); return uhrzeit(); }; } You should pass function rather than call function (adding () is effectively calling the function). This Meteor.setInterval(uhrzeit(), 1000); will effectively be "call <whatever is returned by uhrzeit> every 1 second".

Categories : Javascript

Why is Template.mytemplate.rendered getting triggered twice when trying to animate live changes in Meteor.js?
The template gets rendered twice because two different instances of the same template get rendered. One that changes selected to "selected" and another that changes it to "". This also explains why you have 3 renders when you switch equals to get. Mixing imperative javascript with declarative is always a mess. So here are my two suggestions: Add an if inside the rendered function to make sure you call the transition only in the selected item template instance. Move the transition to the event itself. You might need to use Meteor.setTimeout. Placing the transition in rendered might not be the best option as it will happen every time the template renders. For instance if name changes. Think what would happen when the code gets longer...

Categories : Javascript

How to use this dictionary to show the file information in template in javascript?
Use ajax call : say your ajax_template.html : {% for choice in overview %} <tr> <td><input type="checkbox" name="choice_stop" id="choice{{ forloop.counter }}" value="{{ choice.id }}" onchange="checkChecked_stop()"/></td> <td><label for="choice{{ forloop.counter }}">{{ choice.name }}</label></td> <td>{{ choice.source }}</td> <td><div id="remPercentage{{ forloop.counter }}"></div></td> <td>{{ choice.start_date }}</td> <td><div id="remTime{{ forloop.counter }}"></div></td> <td>{{ choice.human_size }}</td> <td><input type="checkbox" disabled {{ choice.flag_email }} /></td>

Categories : Javascript

Calling information from request inside a django template
Django has a request context processor that adds request object in template context. This is not added by default so you need to enable that in the TEMPLATE_CONTEXT_PROCESSORS settings. However, django adds current request.user as user context variable, so you can use that if that is sufficient.

Categories : Django

Getting database information in Laravel Blade Template with Inner Join
You can always rename the id fields, but that is not necessary. You can specify your columns by using a SELECT query. For example, SELECT address.id as address_id, people.id as people_id. The downside to this method is you'll need to specify every column name.

Categories : Database

Moving subviews from one view to another view without changing any position information in storyboard?
Yes there is an easy way to do this: Step 1: Select your views Step 2: Go Editor > Embed In > Scroll View Done! PS. This is a very handy way to group views in fact. You can embed any views into a 'container' view, move it wherever you like (even cross-scene) retaining relative position information and then you could keep it as a group or unembed them.

Categories : Iphone

in Meteor.template.rendered how to make a call after everything is rendered (after the {{#each}} loop finishes)
I've found Meteor to be a little funny with how often it renders templates, and jQuery functions can end up building up. I've taken to adding console.log("users rendered"); to understand how many times and when the render callback is triggered. One thing I've had some success with is wrapping that template inside another, and then tying the callback to the outside template. Something like this: <template name="container"> {{> users}} </template> <template name="users"> {{#each user}} <li id="{{_id}}"> <input type="checkbox" checked /> <span><select name="colorpicker"> {{#each color}} <option value="{{mColorCode}}" {{selected ../mColor mColorCode}}>{{mColorName}}</option&

Categories : Meteor

Meteor: Could a race condition happen with Meteor.collections on server side?
In Meteor's concurrency model, you can imagine a whole method as an uninterruptible block of stuff that happens. In order for Meteor to switch from running one method midway to say, starting another method, you need to "yield"—the method needs to signal, "I can be interrupted." Methods yield whenever they do something asynchronous, which in practice means any time you do a database update or call a method with a callback in Meteor 0.6.5 and later. Since you give your update call a callback, Meteor will always try to do something in between the call to update and the update's callback. However, in Meteor 0.6.4.2 and earlier, database updates were uninterruptible regardless of the use of callbacks. However, multiple calls to saveOnServer will happen in order and do not cause a race condi

Categories : Javascript

Meteor: meteor-collectionapi PUT overwrites the entire object instead of just updating the field I want
I'm guessing that bash is replacing "$set" with an empty environment variable eg. echo "$set" vs echo "$set" so update your PUT command to: curl -H "X-Auth-Token: 97f0ad9e24ca5e0408a269748d7fe0a0" -X PUT -d "{"$set":{"gender":"Female"}}" http://localhost:3000/collectionapi/players/8BW9Yg2oKByBGdnSa By default Collection.update() will replace a document if no modifiers are present ($set, $unset, $push, $pull etc). So the command being sent to the server is to replace the document with {"":{"gender":"Female"}}

Categories : Api

Meteor Security: should all database insert, update, remove operation be a Meteor.call() to the server?
For the first point, you can choose any of the two possibilities, but i prefer to use the second one : Client can do insert/update/delete Server has some security checks With this system you use the latency compensation of meteor. So it seems to be a good way of doing. For the second point, you can imagine to store in Session where you are on the list when you click on the detail. Then when you come back to the list, you check the session value and you just have to use it to restore the state.

Categories : Javascript

Trying to configure meteor with haml and coffeescript and getting error during meteor startup
there are some work arounds as to where you can install NPM packages directly in Meteor . But the standard practice right now is to use Meteorite for packages. I have not found an HTML preprocessor package that did not give me headaches with MEteor, though, so you might be better off sticking with handlebars. Best of luck!

Categories : Meteor

Code crashed after upgraded from Meteor Windows 0.5.4 to Meteor 0.6.4.1
Since 0.5.4 there have been a couple of changes. The big one being variable scoping. If there is a variable in a file & you want to access that variable from another file you have to scope it globally. i.e if you have var x = true; You have to change it to x = true; The same for a function: function foo() { return "bar"; } //or var foo = function() { return "bar;"} becomes foo = function() { return "bar"; }; You have to go through your files an alter these. Alternatively you could move your files to a new /compatibility directory where they wont be variable scoped.

Categories : Windows

Meteor: Meteor.call() from within observe callback does not execute
This might be a known issue, i'm not sure since I've not tried it myself, but it looks like there might be a workaround (see https://github.com/meteor/meteor/issues/907) Add your Meteor.call into an instantaneous setTimeout callback: added: function(doc) { console.log("added "+doc.text); setTimeout(function() { Meteor.call('aMethod',doc.text,function(e,r){ if(e){ console.log("error from server: "+e); }else{ console.log("response from server: "+r); } }); },0); }

Categories : Javascript

Meteor code must always run within a fiber when deploy in meteor server
You shouldn't need to use Meteor.call on the server side. That is for client-side code only. Just call addQn directly or better yet, inline it since it's just one line of code.

Categories : Mongodb

Installing Meteor-Permission Denied/Run 'meteor update'
Delete all meteor folders In finder (cmd +shft+g) type in "~/.meteor" on the top of the finder window where is has the folder.meteor click and drag folder to trash 2. In finder (cmd +shft+g) type in "/usr/bin/meteor" then drag the meteor folder to trash 3.In /usr/ create a new folder "local" (password required) and inside "local" create a folder "bin" 4. Go back to terminal a run curl install.meteor.com | /bin/sh –

Categories : Meteor



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.