Note that there are some explanatory texts on larger screens.

plurals
  1. POHandlebars Template is not rendered
    primarykey
    data
    text
    <p>Hey I am completly new to Handlebars.js and almost new to JavaScript itself. So I tried to go through the following tut: <a href="http://coenraets.org/blog/phonegap-tutorial/" rel="nofollow">http://coenraets.org/blog/phonegap-tutorial/</a></p> <p>I completed Part 5 and wanted to test the app in the browser. But the page ist blank. Does the browser recognize handlebars.js by himself and renders the handlebars template automatically? Or why do I receive a blank page?</p> <p>I hope the questions is not to basic, however I have no clue how to proceed or where my error lies. index.html:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script id="home-tpl" type="text/x-handlebars-template"&gt; &lt;div class='header'&gt;&lt;h1&gt;Home&lt;/h1&gt;&lt;/div&gt; &lt;div class='search-bar'&gt;&lt;input class='search-key' type="text"/&gt;&lt;/div&gt; &lt;ul class='employee-list'&gt;&lt;/ul&gt; &lt;/script&gt; &lt;script id="employee-li-tpl" type="text/x-handlebars-template"&gt; {{#.}} &lt;li&gt;&lt;a href="#employees/{{this.id}}"&gt;{{this.firstName}} {{this.lastName}}&lt;br/&gt;{{this.title}}&lt;/a&gt;&lt;/li&gt; {{/.}} &lt;/script&gt; &lt;script src="lib/jquery-1.8.2.min.js"&gt;&lt;/script&gt; &lt;script src="js/storage/memory-store.js"&gt;&lt;/script&gt; &lt;script src="js/main.js"&gt;&lt;/script&gt; &lt;script src="lib/handlebars.js"&gt;&lt;/script&gt; &lt;/body&gt; </code></pre> <p></p> <p>main.js:</p> <pre><code>var app = { findByName: function() { var self = this; this.store.findByName($('.search-key').val(), function(employees) { $('.employee-list').html(self.employeeLiTpl(employees)); }); }, initialize: function() { var self = this; this.store = new MemoryStore(function() { self.renderHomeView(); }); this.homeTpl = Handlebars.compile($("#home-tpl").html()); this.employeeLiTpl = Handlebars.compile($("#employee-li-tpl").html()); }, renderHomeView: function() { $('body').html(this.homeTpl()); $('.search-key').on('keyup', $.proxy(this.findByName, this)); }, showAlert: function (message, title) { if (navigator.notification) { navigator.notification.alert(message, null, title, 'OK'); } else { alert(title ? (title + ": " + message) : message); } }, </code></pre> <p>};</p> <p>app.initialize();</p> <p>I get the follwoing errors in main.js: ln. 15: Uncaught ReferenceError: Handlebars is not defined ln 20. :Uncaught TypeError: Object # has no method 'homeTpl' </p> <p>Kind regards, Snafu</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload