lundi 14 mars 2016

Loading Ember.js in HTML with Ember Inspector

I'm trying run a basic ember.js in an HTML file - ie just loading scripts and running js - and I'm having what I would consider 2 basic problems that I can't seem to solve.

I've crunched all my pertinent code into this:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Ember</title>
</head><body>
<h1>Hi</h1>
<div class="container" id="test-app"></div>
</body></html>

<script type="text/javascript" src="jquery-1.12.1.min.js"></script>
<script type="text/javascript" src="moment.min.js"></script>
<script type="text/javascript" src="handlebars-latest.js"></script>
<script type="text/javascript" src="ember-template-compiler.js"></script>
<script type="text/javascript" src="ember.debug.js"></script>

<script type="text/x-handlebars" data-template-name="index">
  <p>These are all of our characters</p>
   <ul>
     {{#each charact in model}}
        <li><a href="#">{{charact}}</a></li> 
     {{/each}}
   </ul>
</script>
<script>
  window.myTest = Ember.Application.create({
         rootElement:"#test-app"
  });

  myTest.IndexRoute = Ember.Route.extend({
     model: function () {
        return ["Mickey Mouse","Donald Duck","Goofey","Pluto","Minnie Mouse","Daisy Duck"];
     }
  });
</script>

The problems I have are that

Ember doesn't seem to 'see' other javascript libraries. While 'jQuery' and 'Ember' itself are displayed in the console output, 'Moment' and 'handlebars' don't appear in this list nor in Ember Inspector's info / library section.

 DEBUG: -------------------------------    ember-template-compiler.js:1404 
 DEBUG: Ember  : 2.4.2+c496347c            ember-template-compiler.js:1404
 DEBUG: jQuery : 1.12.1                    ember-template-compiler.js:1404
 DEBUG: -------------------------------
 VM266:87 Ember Inspector Active

Why not?

Also the {{#each charact in model}} doesn't work, but {{#each model as |charact|}} does. Why is this? Am I doing something wrong or has the basic conditional test form changed?

Thanks, for the help. Kevin




Aucun commentaire:

Enregistrer un commentaire