Note that there are some explanatory texts on larger screens.

plurals
  1. POHandelbars.js: rendered HTML code not displayed
    primarykey
    data
    text
    <p>I new to Handelbars.js and I wanted to test it out. I just have one html file, whose content I want to be rendered by handlebars.js:</p> <p>HTML file:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; console.log("Head:getting css"); &lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="css/main_2.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="phone-screen"&gt; &lt;script type="text/javascript"&gt; console.log("Body:start MasterPage"); &lt;/script&gt; &lt;!--MasterPage --&gt; &lt;script id="app-bar" type="text/x-handlebars-template"&gt; &lt;div class="app-bar-container"&gt; &lt;/div&gt; &lt;div class="nav-bar-container"&gt; &lt;div class="nav-tab-left nav-tab-selected nav-tab-label-Selected"&gt; &lt;div class="tab-lable-centered "&gt;History&lt;/div&gt; &lt;/div&gt; &lt;div class="nav-tab-right nav-tab-notSelected "&gt; &lt;div class="tab-lable-centered "&gt;New&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/script &lt;!-- Content --&gt; &lt;script id="workout-list-tpl" type="text/x-handlebars-template"&gt; &lt;div class="list-container"&gt; &lt;div class="week-seperator"&gt; &lt;div class="week-lable-right "&gt;Week 12&lt;/div&gt; &lt;/div&gt; &lt;div class="workout-card-white"&gt; &lt;div class="workout-card-label "&gt;Workout&lt;/div&gt; &lt;/div&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; console.log("Body:getting Scripts________________________"); &lt;/script&gt; &lt;script src="lib/handlebars.js"&gt;&lt;/script&gt; &lt;script src="js/storage/memory-store.js"&gt;&lt;/script&gt; &lt;script src="lib/jquery-1.8.2.min.js"&gt;&lt;/script&gt; &lt;script src="js/MainView.js"&gt;&lt;/script&gt; &lt;!--&lt;script src="js/EmployeeView.js"&gt;&lt;/script&gt;--&gt; &lt;script src="js/main_2.js"&gt;&lt;/script&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p></p> <p>The app javascript:</p> <pre><code>var app = { initialize: function() { console.log("initializer start: "); var self = this; //this.detailsURL = /^#employees\/(\d{1,})/; //this.registerEvents(); this.store = new MemoryStore(function() { self.route(); }); }, route: function() { console.log("route function start."); var self = this; var hash = window.location.hash; if (!hash) { if (this.homePage) { //this.slidePage(this.homePage); } else { console.log("homePage: "); this.homePage = new MainView(this.store).render(); console.log("homePage = " + this.homePage ); //this.slidePage(this.homePage); } return; } var match = hash.match(this.detailsURL); if (match) { //this.store.findById(Number(match[1]), function(employee) { //self.slidePage(new EmployeeView(employee).render()); //}); } }, showAlert: function (message, title) { if (navigator.notification) { navigator.notification.alert(message, null, title, 'OK'); } else { alert(title ? (title + ": " + message) : message); } }, }; console.log("app.initialize();"); app.initialize(); </code></pre> <p>And the view.js:</p> <pre><code>var MainView = function(store) { this.render = function() { console.log("render function execution:" + MainView.template() ); this.el.html(MainView.template()); return this; }; this.initialize = function() { console.log("MainView init start."); // Define a div wrapper for the view. The div wrapper is used to attach events. this.el = $('&lt;div/&gt;'); //this.el.on('keyup', '.search-key', this.findByName); }; this.initialize(); } console.log("Handlebars.compile($(app-bar).html()); " ); MainView.template = Handlebars.compile($("#app-bar").html()); </code></pre> <p>console log:</p> <pre><code>Head:getting css main_2.html:4 Body:start MasterPage main_2.html:12 Body:getting Scripts________________________ main_2.html:41 Handlebars.compile($(app-bar).html()); MainView.js:19 app.initialize(); main_2.js:46 initializer start: main_2.js:5 route function start. main_2.js:15 homePage: main_2.js:22 MainView init start. MainView.js:10 render function execution: &lt;div class="app-bar-container"&gt; &lt;/div&gt; &lt;div class="nav-bar-container"&gt; &lt;div class="nav-tab-left nav-tab-selected nav-tab-label-Selected"&gt; &lt;div class="tab-lable-centered "&gt;History&lt;/div&gt; &lt;/div&gt; &lt;div class="nav-tab-right nav-tab-notSelected "&gt; &lt;div class="tab-lable-centered "&gt;New&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; MainView.js:4 homePage = [object Object] </code></pre> <p>The code goes through to the render function in view.js getting the html code but I do not know what happens next and hence why it is not rendered in the browser.</p>
    singulars
    1. This table or related slice is empty.
    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