Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 运行在sails.ejs文件中定义的主干视图模板_Javascript_Backbone.js_Sails.js_Marionette_Ejs - Fatal编程技术网

Javascript 运行在sails.ejs文件中定义的主干视图模板

Javascript 运行在sails.ejs文件中定义的主干视图模板,javascript,backbone.js,sails.js,marionette,ejs,Javascript,Backbone.js,Sails.js,Marionette,Ejs,我将主干木偶网与server node.js-sails.js一起使用 我在index.ejs中有以下代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <div id="header-region"></div> <div id="main-

我将主干木偶网与server node.js-sails.js一起使用

我在index.ejs中有以下代码:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
  </head>

  <body>

    <div id="header-region"></div>

    <div id="main-region" class="container">
      <p></p>
    </div>

    <script type="text/template" id="admin">
      <div > <%= name %> </div>
    </script>

  </body>
</html>
但是当加载index.ejs时(而不是在templateHelper中调用它时),我得到一个错误:
name未定义

正如我所知,它应该只在调用时运行!或者
html
ejs
之间可能存在差异?

App.request()
异步函数吗?如果是这样的话,它基本上是发出一个请求调用,下一行
var compiled…
运行时没有异步调用的返回值,留下一个未定义的值。如果是这种情况,您需要将其放入成功回调中。
templateHelpers: {
        getData: function(){
          require(["apps/models/userRole"]);
          data = App.request("userRole:role", this);
          var compiled = _.template($("#" + data.name).html(), this);
          return compiled;
        }
},