Tag: backbone.js

服务器上的Node.js和Backbone.js路由器

有没有人在node.js服务器中使用骨干路由器? 也许有些扩展是允许这个?

'npm install bones'安装旧版本的下划线

你能帮我解决一下npm安装function有些神秘的行为。 'Npm install bones'安装旧版本的下划线(1.1.7)而不是1.4.2。 问题是旧版本包含一些错误,这些错误导致我的代码出现问题。 在bones目录下的'npm install underscore'会做同样的事情,而在这个目录之外安装正确的版本。 根据骨骼安装的官方规范(https://npmjs.org/package/bones),应该安装新版本。 任何想法如何克服这一点? 我可以做一个git克隆,但我试图避免这种情况。 谢谢

Express / NodeJS上的CORS问题,在Internet Explorer中不可用的服务

我有一个基于REST的服务写在Express / NodeJS上。 我已经编写了CORS(跨源资源共享)实现代码。 和服务可以从浏览器,如铬,Firefox等消耗..但不是从Internet Explorer,(我使用IE9,我检查了IE浏览器IE-10,CORS错误信息仍然存在于控制台中) CODE FROM routes.js节点服务器端的文件 var config = require('./config.js'); exports.setup = function (params) { var controllers = params.controllers; var app = params.app; // CORS (Cross Origin Resource Sharing) Implementation app.all('/*', function(req, res, next) { res.header("Access-Control-Allow-Credentials", config.responseSettings.AccessControlAllowCredentials); res.header("Access-Control-Allow-Origin", (req.headers.origin) ? req.headers.origin : config.responseSettings.AccessControlAllowOrigin); res.header("Access-Control-Allow-Headers", (req.headers['access-control-request-headers']) ? req.headers['access-control-request-headers'] : "x-requested-with"); res.header("Access-Control-Allow-Methods", (req.headers['access-control-request-method']) ? […]

Node.js和Backbone.marionette初始视图

目前,我有一个Node.js应用程序用我的服务器端模板语言(在这种情况下,玉)服务我的静态/login & /index HTML页面。 我想成功的身份validation后,返回有关当前login用户的数据,以便骨干可以开始呈现内容。 例如,我在Mongo中有一个UserGroup文档,用于存储有关User信息以及他们属于哪个组(授权信息)。 使用护照,我可以validation我的用户,并将其redirect到主页面。 app.post('/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true }) ); redirect后,我怎么能发送有关骨干将在首次渲染的'/'骨干路由中拿起的用户的数据? 这将是res.send()即使它不是发起第一个请求的骨干,也不是使用关于用户的元数据的会话。

jQuery的手机redirect或更改url时,网页没有任何CSS

我正在与骨干,jQuery的移动,快递应用程序。 一切正常,当应用程序启动和正常工作,但是,当我点击一个链接或更改url的HTML呈现正确,但没有jQuery的移动魔术出现。 它只在页面和页脚和格式的login部分呈现,但是当URL改变,我回来了,页面失去了CSS或jQuery的移动魔术。 define(['views/index', 'views/register', 'views/login', 'views/forgotpassword', 'views/profile', 'views/vinbookDoc', 'models/Account', 'models/Vinbook', 'models/vinBooksCollection'], function(IndexView, RegisterView, LoginView, ForgotPasswordView, ProfileView, vinbookDocView, Account, Vinbook, vinBooksCollection) { var AppRouter = Backbone.Router.extend({ currentView: null, routes: { "index": "index", "login": "login", "desk/:id": "desk", "profile/:id": "profile", "register": "register", "forgotpassword": "forgotpassword", "vinbook/:id": "showVinbook" }, initialize: function(){ $('.back').live('click', function(event) { window.history.back(); return false; }); this.firstPage […]

保存用户的collections夹

我试图将用passport.jsvalidation的用户与backbone.js集合或一个id数组(我不是哪个解决scheme是最好的)关联起来,并将其保存在mongoDB中。 我在服务器端使用node.js。 可能吗? (例如保存用户的最爱)。

Express.js性能问题

Express.js有性能瓶颈。 情况如下。 客户端是Backbone / Marionette / RequireJS完整的SPA.Server是用sails.js编写的。 Sails仅用作REST服务器(不提供任何HTML)。这两种应用程序都在AWS-Windows实例的一台机器上提供。 WIndows服务器2012 32x。 帆是作为单独的节点进程服务的。 客户是另一个独立的过程。 服务器响应时间是即时的,而客户端是可怕的。 * .js文件不断下载一次又一次。 这里是我仅用于服务客户端的脚本。 "use strict"; process.env.NODE_ENV = "production"; var allowCrossDomain = function (req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); res.header('Access-Control-Allow-Headers', 'content-type, Authorization, Content-Length, X-Requested-With, Origin, Accept'); if ('OPTIONS' === req.method) { res.send(200); } else { next(); } }; var path = […]

集成骨干与Nodejs

尝试从骨干模型获取Nodejs响应。 更新 更改模型代码如下,并获得错误 XMLHttpRequest无法加载http://localhost:3000/getDifficulty 。 请求的资源上没有“Access-Control-Allow-Origin”标题。 原因'null'因此不被允许访问。 var Bitcoin = Backbone.Model.extend({ url:'http://localhost:3000/getDifficulty' }); var info = new Bitcoin (); info.fetch(); 节点的JS是非常直接的,并为http://localhost:3000/getDifficulty 服务器端节点JS var http = require('http'), express = require('express'), bitcoin = require('bitcoin'); var app = express(); var client = new bitcoin.Client({ host: 'localhost', port: 8332, user: 'himanshuy', pass: 'xxx' }); app.get('/getDifficulty', function(req, res) { client.getInfo(function(err, […]

将Flash消息暴露给Handlebars模板

我正在构buildSPA:Backbone.js,Node.js,Mongo。 我使用Passport.js进行身份validation,并想知道如何将req.flashvariables暴露给我的Handlebars模板? 在这种情况下,如果用户试图用电子邮件login,我想在我的视图中公开flashvariables“signupMessage”。 在我的Express服务器上: app.use(function(req, res, next){ res.locals.flash = req.flash next(); }); 护照本地策略: passport.use('local-signup', new LocalStrategy({ usernameField : 'email', passwordField : 'password', petnameField : 'petname', passReqToCallback : true // allows us to pass back the entire request to the callback }, function(req, email, password, done) { process.nextTick(function() { User.findOne({ 'local.email' : email }, function(err, user) […]

使用Backbone.js创build一个模态

我是Backbone的新手,虽然我做了一些研究,但在创buildModal方面,找不到解决scheme。 我想创build一个基础Modal类,然后重用/扩展它,并在我的其他视图/类中应用不同的模板。 这是我的Modal基类: define([ // Application. 'app', 'backbone', 'plugins/jquery-ui.custom', 'moment' ], function(App, Backbone) { // Create a new module. var Modal = App.module(); Modal.View = Backbone.View.extend({ className: 'ui-modal', render: function () { console.log('this.$el',this.$el,'this.template',this.template); this.$el.html(this.template()); this.$el.delegate('.close', 'click', this.closeModal); this.error = this.$el.find('.error'); return this; }, closeModal: function (ev) { if (ev) ev.preventDefault(); this.$el.unbind(); this.$el.empty(); this.$el.remove(); }, initialize: […]