Tag: backbone.js

Binding To ItemView the change Events

I would like to re-render a list made using Marionette.ItemView when the corresponding model in ItemView change. Any idea about the best way to active this task? // Collection passed to Marionette.CompositeView myCollection.attributes = [ { id: 1, name: ‘bar’ closed: false }, …. ]; // Marionette.ItemView myModel.set({ closed: true }); // when this model […]

Backbone.js View Tagname set dynamically?

I’m trying to set up the base architecture for a Phonegap project using jQueryMobile and Backbone.js We will be targeting multiple platforms and plan on expanding in the future. I want my Backbone code to be completely ignorant of the types of HTML elements associated with the Views since we have no idea what the […]

How to remove default link in JS text/template

Anyone can help me on how to remove or replace existing link in JS templating. I use backbone.js for this. Here is my code: <script id=”option-show-template” type=”text/template”> <address> <abbr title=”Website”>Web :</abbr> <%= (website)? ‘<a href=”‘+ website +'” id=”website”>’ + website + ‘</a>’ : ” %></address> </script> Output: Web: www.test.com The Problem is even though it […]

this.each not iterating through collection correctly

I’ve just started using backbone.js and I’m adding some basic methods to extend a collection allowing me to iterate through a collection and save all models, and iterate through a collection to destroy all models. I realise that bulk updates aren’t RESTful, but I’m only updating to local storage so didn’t think it would be […]

Backbone js: Not getting data from model while fetching data using rest api in collection

//Declare model app.models.Items =Backbone.Model.extend({ defaults: { id: ”, name : ” } }); //fetch data using collection app.models.ItemsCollection = Backbone.Collection.extend({ model: app.models.Items, url: urlprefix + id + “/items”, }); //Create Instance of Collection app.models.ItemsModel = new app.models.ItemsCollection(); app.models.ItemsModel.fetch({ async: false, // in success get response and add response in model success: function(response) { for (i […]

Require.js load timeout for jquery/underscore/backbone/parse modules

Uncaught Error: Load timeout for modules: order!libs/jquery/jquery-min order!libs/underscore/underscore-min order!libs/parse/parse-min libs/jquery/jquery-min libs/underscore/underscore-min libs/parse/parse-min Backbone http://requirejs.org/docs/errors.html#timeout I have no 404 requests under the Network tab of Chrome, and I have no script errors, so I am outside of the common bugs/fixes for the problem (according to requirejs.org). When I look at my Network, I see that the […]

Making jQuery, Backbone, etc global variables in Browserify

I have a relatively large app built with Backbone and Marionette. That means that at the top of every file I have something like: var _ = require(‘underscore’); var $ = require(‘jquery’); var Backbone = require(‘backbone’); Backbone.$ = $; var Marionette = require(‘backbone.marionette’); I know that part of the idea of Browserify is that there […]

Backbone.js Parse Method

I am trying to unit test my first backbone.js application using sinon.js and jasmine.js. In this particular test case, I used the sinon.js fakeServer method to return a dummy response with the following structure. beforeEach( function(){ this.fixtures = { Tasks:{ valid:{ “tasks”:[ { id: 4, name:’Need to complete tests’, status: 0 }, { id: 2, […]

Backbone Collection fetching throwing id error

I’m trying to figure out Backbone.js and am going through the PeepeCode backbone.js basics video. When I try and fetch the collection in the Chrome’s Javascript console, it throws the following error: Uncaught TypeError: Cannot use ‘in’ operator to search for ‘id’ in [{ here is my json: [{ “id” : “1”, “title”: “Bound – […]

backbone views that create views

So here is the thing. I’m making an app that uses backboneJS. I currently create a list of different rows. Each row has an edit button with the function editRow and a delete button with the function removeRow. Currently editRow works and it creates the new view which in this case is a modalWindow and […]