backbone.js

API for backbone will be accessible by other website or devices

柔情痞子 提交于 2020-01-17 07:12:10
问题 I am new in backbone, I am using php with Laravel framework as my server side language. I read to creating a single page application, I should create an API on my server side. Is this right (I should have an API for backbone single page application)? Is this secure? (Other websites or devices like Android software can access it?) 来源: https://stackoverflow.com/questions/28734575/api-for-backbone-will-be-accessible-by-other-website-or-devices

Model is not a constructor-Backbone

江枫思渺然 提交于 2020-01-17 05:02:11
问题 I have created a model and collection for a json to be fetched as shown here.When i'm instantiating in the service i'm getting error that my model is not a constructor.My model uses collection of models for storing time/value pairs. ServiceMonitoringModel.js define(function(require) { 'use strict'; var _ = require('underscore'); var Backbone = require('backbone'); var ServiceMonitoringCollection=require('./ServiceMonitoringCollection'); var ServiceMonitoringModel = Backbone.Model.extend({

backbone.js: accessing a property on deeplinked page

孤街醉人 提交于 2020-01-16 11:22:12
问题 I am working on an example using a router to switch to a new view. In this example the view's render function is using a console.log to successfully outputs the attributes, including the id, but the template does not display the id. I have tried to only put the relevant sections of the application here. var DetailView = Backbone.View.extend({ el: $('body'), template: _.template('this is detailview for <% id %><a href="index.htm">back</a>'), render: function(id){ var attributes = this.model

backbone.js: accessing a property on deeplinked page

元气小坏坏 提交于 2020-01-16 11:22:08
问题 I am working on an example using a router to switch to a new view. In this example the view's render function is using a console.log to successfully outputs the attributes, including the id, but the template does not display the id. I have tried to only put the relevant sections of the application here. var DetailView = Backbone.View.extend({ el: $('body'), template: _.template('this is detailview for <% id %><a href="index.htm">back</a>'), render: function(id){ var attributes = this.model

How to format carriage returns in a Backbone model in a Mustache template

余生颓废 提交于 2020-01-16 09:41:34
问题 I'm using Backbone models as input into Mustache templates to generate HTML. I have a Backbone model with a number of attributes, such as name, description and id. The description attribute can contain carriage returns, which I want to render as <br> tags when they're rendered in the template. By default, Mustache simply outputs the carriage returns directly, so the markup looks tidy, but the rendered result has no breaks. I don't particularly want to replace \n\r in the description attribute

How to bind context of child view handling event in parent view

ε祈祈猫儿з 提交于 2020-01-16 09:41:13
问题 I have the following Backbone View's: var ParentView = Backbone.View.extend({ events: { "contextmenu .child-view" : "handleChildView" }, initialize: function () { // create child view var child = new ChildView; }, handleChildView: function () { } }); var ChildView = Backbone.View.extend({ initialize: function () { this.el.addClass('child-view'); } }); I need to handle childView's contextmenu event in handleChildView handler. But I need to get refference to childView and target DOM element.

backbone.sync get all response error status codes

柔情痞子 提交于 2020-01-16 08:06:10
问题 In the end, I want to catch a 302 error and redirect to my login page, but right now xhr.status is getting a status code of 200. Here's my current code: parentSyncMethod = Backbone.sync Backbone.sync = (method, model, options) -> old_error = options.old_error options.error = (xhr, text_status, error_thrown) -> if(xhr.status == 302) window.location.replace('http://localhost:8080/login') else old_error?(xhr, text_status, error_thrown) parentSyncMethod(method, model, options) basically I think

binding events to dynamic objects in underscore/backbone

风格不统一 提交于 2020-01-16 04:21:29
问题 I'm trying to figure out how to listen for custom events on objects which have not been prototyped or are not dom objects in underscore.js/backbone.js. for example: //this is inside a view object play: function(arg) { this.a = this.image(this.model.a); this.a.bind("ready",start,this);//<--- causes error this.b = this.image(this.model.b); this.b.bind("ready",start,this);//<--- causes error function start() { // do some stuff in here } //some more stuff }, image: function(args) { // load the

CSRF verification failing in django/backbone.js

前提是你 提交于 2020-01-16 02:52:07
问题 I'm trying to recreate a small project from lightweight django - https://github.com/lightweightdjango/examples/tree/chapter-5 I'm getting a CSRF error when trying to login with the superuser account. Below is my models.js (function ($, Backbone, _, app) { // CSRF helper functions taken directly from Django docs function csrfSafeMethod(method) { // these HTTP methods do not require CSRF protection return (/^(GET|HEAD|OPTIONS|TRACE)$/i.test(method)); } function getCookie(name) { var cookieValue

Accessing res.locals from Backbone.Router templates

本小妞迷上赌 提交于 2020-01-15 23:07:18
问题 I've been working on a very basic nodejs problem for way too long at this point and I'm stuck. Others have asked similar questions but for some reason the answers don't seem to work for me. Background: I'm just ramping up with NodeJS with Express, Backbone, & Passport for auth. Passport stores the user object in the request so I'm trying to pass it up to my Backbone views. I've been using the Node Cellar project as a starting point and have followed their lead in displaying most of my views