html - Getting "cannot call method ... of undefined" error with JavaScript and Mustache -


i'm using html, javascript, , jquery mobile make kind of picture gallery. i'm following jqm demo at: http://jquerymobile.com/demos/1.3.0-beta.1/docs/demos/swipe/swipe-page.html make gallery, uses totally different html page each picture. plan gallery dynamic, don't have set number of pages or set list of picture names, etc, , thought might use mustache make picture template, , create pages dynamically. here basic layout of code:

in index.html

<!doctype html>  <html> <head>     ...     <script src="mustache-0.7.0-min.js" type="text/javascript"></script>     <script src="mobile.js" type="text/javascript"></script>     <script id="test_template" type="text/html">         <h1>{{firstname}} {{lastname}}</h1>         <p>{{temptext}}</p>     </script>     ... </head> ... 

and in mobile.js

function showperson()  {       var person =          {             firstname: "feaf",             lastname:  "mcfeaf",             temptext:  "hello feaf"         };      var persontemplate = document.getelementbyid("test_template").innerhtml;      var html = mustache.to_html(x, person);  } 

so it's basic can get. however, when run web app on local server (in chrome), , step through function, error @ mustache.to_html line, saying

uncaught typeerror: cannot call method 'to_html' of undefined 

i'm new web development, , brand new mustache, not know causing error. i've tried calling other mustache methods, render, same error appears. <script src=...> not enough have mustache library accessible mobile.js? have tips on might doing wrong?

thank information, , let me know of other information should add.

edit:

whoops! forgot include fact had mustache in scripts section, i've edited reflect fact. clear, have (and have had) mustache included!

also, tried suggestion of @zorayr of using console.log(mustache), , claims mustache undefined, though importing noted above. why might be?

as solution problem, ended downloading , using handlebars. seems me there conflict mustache library in project , new 1 added in. doesn't explain why mustache undefined, workaround.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -