squ*_*ime 13 javascript router backbone.js meteor
在我的Meteor应用程序中,Backbone路由器仅在用户登录时才能工作(通过基于帐户的程序包).真奇怪.这个路由器本身工作正常.showSaying()当用户未登录时,根本不调用该函数.
下面是client.js客户端文件夹中的代码.我是否需要对会话或自动发布做些什么?
AphorismView = Backbone.View.extend({
el: "#aphorism-item",
initialize: function(){
_.bindAll(this, "render");
this.render();
},
render: function() {
this.$el.append("<p style='height:600px; background-color:blue;'>hi</p>");
}
});
// Creates a route to view the selected aphorism
var Aphorism = Backbone.Router.extend({
routes: {
"saying/:id": "showSaying"
},
showSaying: function (id) {
var aphorism_view = new AphorismView();
alert('Saying id ' + id + '.');
}
});
//establishes the router
appRouter = new Aphorism;
//Sets up backbone
Meteor.startup(function () {
filepicker.setKey("AerIOvsmAQRGaNdEv0judz");
filepicker.constructWidget(document.getElementById('attachment'));
Backbone.history.start({pushState: true});
});
Run Code Online (Sandbox Code Playgroud)
您的问题看起来根本不像 Backbone.js 问题。
您是否尝试过在回调中放入 console.log 语句startup()以验证它在所有情况下是否确实被调用?如果没有,那就是你和 Meteor 之间的事情了。
| 归档时间: |
|
| 查看次数: |
884 次 |
| 最近记录: |