Where is the parseTime() function defined? - chart.js

I'm trying to use the code from this fiddle:
https://jsfiddle.net/lenyy/2e0u7u3k/
At several places it calls me.parseTime(), but I can't figure out where that function is defined. I'm guessing it's part of Chart.js helpers or something?
Where is parseTime defined?

Related

Checking the text within a div using React Enzyme

Doing a shallow rendering, I'm working with the following and trying to use the .get() function in order to check the text within the node. My page has multiples of the class tag-cloud__section. I've found that .html and .text returns an error that they are not a function. What am I misunderstanding here?
expect(wrapper.find('.tag-cloud__section').get(0).text()).toContain('these words');
The project I'm on is using 3.3, but I haven't seen anything mentioning in the docs that its a newer feature. Any tips, pointers or exposing of my ignorance is appreciated!
You are able to use both .first() and .at(0) to perform this action

Dots on Meteor Templates Names

So, I've been trying to create a Template called "Chart.Line" using Meteor's Spacebar syntax. So, if I do this:
<template name="Chart">
// random stuff here
</template>
and later import it using {{> Chart}} anywhere I want, then all the random stuff runs as expected. But if I define the Template like this:
<template name="Chart.List">
// random stuff here
</template>
then, nothing works.
My question is: what's wrong here? I've been looking on documentation and source code forever, but I can't figure out what's wrong with using dots on this particular situation.
P.S.: yes, calling it "Chart.List" instead of "Chart_List" or something similar would be extremelly desirable.
You can use dots in a template name.
Blaze will try and access the List property of Chart instead of the template called Chart.List (as was mentioned in the comments).

Custom tag using the Cffunction Tag

I am trying to create a custom tag for cffunction for trying to reuse and not write cffunction again and again, I am using the following as:
<cffunction access="#attributes.access#" returntype="#attributes.return#" output="#attributes.output#" name="#attributes.method#">
but cfbuilder version 2 is giving me illegal attribute error, i am not sure, it is right or wrong, can i do like this
Thanks
No, you cannot use dynamic values (variables) in attributes of <cffunction>. Functions are pre-compiled and thus do not allow evaluation at runtime.
If your reason to wrap all functions is to catch errors, there are better approaches to do so, e.g. the onError handler.

Is the "loading" template special in Ember.js?

I see that the following template is rendered if loading the model takes a long time:
<script type="text/x-handlebars" data-template-name="loading">
<h1>Loading</h1>
</script>
The Route must be defined:
App.LoadingRoute = Ember.Route.extend({});
But the router needs no configuration for this to be active. I think this is ember-related behavior (although it could also be handlebars-related, but I do not think so).
Are there other special template names?
Where is this magic documented? (not possible to find it in the Ember documentation)
As you already noticed the router needs no definition for the LoadingRoute since it's somewhat special. The LoadingRoute will be looked up by ember, and if it's find one it is used for exact the expected behavior.
Have a look at this jsbin for an simulated loading example.
Are there other special template names?
Yes, there is also a special route called FailureRoute which can be used to handle errors globally.
Where is this magic documented? (not possible to find it in the Ember documentation)
As for some documentation on this please see this gist. Some of the changes where introduced not long ago, so documentation is somewhat sparse.
Hope it helps.

Emberjs - unable to redefine named, explicitly compiled Handlebars template

As part of an attempt to port a fairly large/complex existing application to the Ember world, I'm generating and compiling named Handlebars templates dynamically, and associating views with them, using the technique:
var template = Ember.Handlebars.compile("some handlebars stuff");
Ember.TEMPLATES["myTemplate"] = template;
var view = Ember.View.create({
templateName: "myTemplate"
});
One of the things I'd like to do is be able to recompile new/different Handlebars template markup which overwrites the template named "myTemplate" and have it be accessible to views at that name.
I'm getting unexpected results trying to do this - a couple fiddles that illustrate the problems:
First fiddle - Shows what happens if you wait before rendering a view after the named template contents have changed.
Second fiddle - Shows what happens if there's no delay before rendering a view after the named template contents have changed.
There's obviously some magic under the hood that I'm not understanding. Can anyone shed some light on this?
UPDATE:
I went through the source code for Ember.View and the container module, and came to realize that I could solve the problem in the First fiddle by overriding the "template" computed property in a way that skips the container cache lookup. I've put up another fiddle here to demonstrate the solution I found.
This seems to be working the way I'd like it to - but - it feels like I might be fighting with the framework and "unhooking" from the container in a way that might bite me later. Is there a better, more Ember-esque way to accomplish what I'm trying to do? Will the hack I found break things?
UPDATE 2
I've also discovered that it's also possible to simply call
view2.get('container').reset();
before appending view2 in the First fiddle. Seems cleaner/safer, but is it "legal"? I've updated the First fiddle to illustrate this.
(in the second fiddle, both views show the second template)
This is because view1.appendTo($("#target")); just schedules the append, actual view rendering does not happen until end of the run loop. Before that happens, you've set Ember.TEMPLATES["myTemplate"] = template2;
(in the first fiddle, both views show the first template)
Pretty sure this is because ember container caches template fx, but not 100% on that. Checking...
I'm going to call this one answered. As I mentioned in my second comment, I'm using the solution shown in this fiddle in my project, along these lines:
mYiew.get('container').reset();
There's some discussion about the container not being intended to be used as an API here: https://github.com/emberjs/ember.js/commit/5becdc4467573f80a5c5dbb51d97c6b9239714a8 , but there doesn't seem to be any mention of using the container from Views for other use cases.
Also, a View's container can be accessed directly (at ".container") - meaning the devs haven't made it "hard" to get to the way they have for an Application's ".__ container __". This might suggest something about how they intend it to be used.
Since a View having the ability to clear its cache whenever it wants to doesn't seem to me to be unreasonable or a bad practice, I'm using the above mentioned solution...at least until someone sets me straight with a better idea (or a cache API).