请参阅下面的更新
我用Express编写了一个Node.js应用程序,在本地工作正常,但是当我在Heroku上运行应用程序时,它给出了以下错误:
2013-01-19T21:55:42+00:00 app[web.1]: module.js:340
2013-01-19T21:55:42+00:00 app[web.1]: throw err;
2013-01-19T21:55:42+00:00 app[web.1]: ^
2013-01-19T21:55:42+00:00 app[web.1]: Error: Cannot find module './blog/blog'
2013-01-19T21:55:42+00:00 app[web.1]: at Function.Module._load (module.js:312:12)
2013-01-19T21:55:42+00:00 app[web.1]: at Module.require (module.js:362:17)
2013-01-19T21:55:42+00:00 app[web.1]: at Object.Module._extensions..js (module.js:467:10)
2013-01-19T21:55:42+00:00 app[web.1]: at require (module.js:378:17)
2013-01-19T21:55:42+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:15:12)
2013-01-19T21:55:42+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:338:15)
2013-01-19T21:55:42+00:00 app[web.1]: at Module.load (module.js:356:32)
2013-01-19T21:55:42+00:00 app[web.1]: at Module.runMain (module.js:492:10)
2013-01-19T21:55:42+00:00 app[web.1]: at Function.Module._load (module.js:280:25)
2013-01-19T21:55:42+00:00 app[web.1]: at Module._compile (module.js:449:26)
2013-01-19T21:55:43+00:00 heroku[web.1]: Process exited with status 1
2013-01-19T21:55:43+00:00 heroku[web.1]: State changed …Run Code Online (Sandbox Code Playgroud) 我试图找到一种方法将正则表达式输入到快速路由URL中,然后通过请求对象访问URL的变量部分.具体来说,我想路由到网址"/ posts /"+任意数量的数字.有没有办法做到这一点?
例子:
/posts/54
/posts/2
/posts/546
Run Code Online (Sandbox Code Playgroud) 我正在编写一个Ember.js应用程序,我希望在视图渲染后立即在div一个类上运行以下Javascript代码navbar:
$('.navbar').affix({offset: -1000});
Run Code Online (Sandbox Code Playgroud)
我不知道在Ember中可以轻松地做到这一点,因为标准的JQuery $(document).ready()不能与Ember应用程序一起使用.必须有一些简单的方法来做到这一点,但这个问题的所有其他答案似乎都是复杂的解决方法,并且基于过时的Ember.js版本.
问题模板:
<script type="text/x-handlebars">
<div class="navbar" data-spy="affix">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
</div>
</div>
</div>
{{outlet}}
</script>
Run Code Online (Sandbox Code Playgroud) 我想写一个函数,它接受一个List<Object>并返回一个原始列表,该列表被转换为一个指定对象类型的列表List<ObjectType>,知道原始列表中的对象是类型ObjectType.诀窍是ObjectType可以是任何类型,我发现使用反射.很抱歉没有代码,但我没理由知道我甚至可能会这样做.
我成功地让我的应用程序在foreman上运行得很好,但是一旦我将它部署到Heroku,就会在日志中抛出错误:
2012-08-20T03:22:48+00:00 heroku[web.1]: Starting process with command `node index.js`
2012-08-20T03:22:49+00:00 app[web.1]: Server has started.
2012-08-20T03:22:49+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 15134, should be 52717 (see environment variable PORT)
2012-08-20T03:22:49+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-08-20T03:22:51+00:00 heroku[web.1]: Process exited with status 137
2012-08-20T03:22:51+00:00 heroku[web.1]: State changed from starting to crashed
Run Code Online (Sandbox Code Playgroud)
我试图更改它绑定的端口,但每次我更改端口.我的应用程序中还有其他错误吗?
我想,当一个给定的集合中的变化对模型进行烧制,实施一项行动,但每当我试图把一个监听器上change,add或remove在我收集的事件,没有事件被触发.当我将更改事件附加到模型的initialize函数(只是为了测试)时,change事件被成功触发.下面的视图本身不会更改代码,但我希望每当对集合进行更改时它都会重新呈现.我的设置可能有问题,但我想得到你的建议.以下是我的代码:
contact.js(型号):
define([
'jquery',
'underscore',
'backbone'
], function($, _, Backbone){
var ContactModel = Backbone.Model.extend({
urlRoot: '/contacts'
});
return ContactModel;
});
Run Code Online (Sandbox Code Playgroud)
contacts.js(收藏):
define([
'jquery',
'underscore',
'backbone',
'models/contact'
], function($, _, Backbone, Contact){
var ContactCollection = Backbone.Collection.extend({
url: '/contacts',
model: Contact
});
return ContactCollection;
});
Run Code Online (Sandbox Code Playgroud)
contactlist.js(查看):
define([
'jquery',
'underscore',
'backbone',
'text!templates/contactlist.html',
'collections/contacts'
], function($, _, Backbone, contactListTemplate, Contacts){
var ContactListView = Backbone.View.extend({
el: '.contact-list',
render: function(options) {
var that = this;
var …Run Code Online (Sandbox Code Playgroud) node.js ×3
express ×2
heroku ×2
javascript ×2
backbone.js ×1
c# ×1
ember.js ×1
foreman ×1
generics ×1
git ×1
html ×1
jquery ×1
module ×1
reflection ×1
regex ×1