Tag: backbone.js

Models vs Views in Backbone.js

From couple of days, I have started working/learning the backbone.js. I have read documentation on their site. I have also read few tutorials available here. As per my understanding below are few major differences between Views and Models. Only view has ‘el’. Why it is not there in Model ? Only Models have ‘get’,’set’, ‘save’ […]

Backbone shared collections

I’m starting with Backbone and stumbled upon a question recently. The sample application I’m working on is some kind of playlist. I have a model ‘song’ and a collection ‘Playlist’, containing several songs. The data of the Playlist-collection should be available in multiple views. So my idea is to have global application-variables, and one of […]

Backbone.js how do i define a custom set of routes depending on a certain application state

Currently building an app that runs on mobile phones not related to the issue at hand, but through a certain event the app lands in a state, either online or offline (internet available on the phone or not) the offline app is very limited, only a few screens available) now stop me if you catch […]

Unit test with a Marionette.CompositeView

By using jasmine, I am trying to test a javascript module which returns a Marionette.CompositeView. Here are the javascript module(2) and the javascript unit-test(1). My question is how to access the rendered view from the (1)? Please see the comment on the code for more details. P.S.: 1) The javascript module works producing the right […]

change model fields automatically when view changed in backbone.js

I have a pop up with plenty of options which can be edited – this is a Backbone View. I have a model which is simple POCO that stores those options. It’s quite hard to write each view event handler to update the model’s corresponding values. How do I update the model automatically when its […]

Backbone views design for standard menubar / detail pages mobile UI

I’m building a mobile web app and have been struggling with the design and wiring of my backbone views. Let me illustrate what I would like to achieve. As you can see, the image above identifies few UI components: Toolbar view with back, search and menu button Tabbed view with lists Detail view Menu view […]

Backbone – populate collection from json and update view

I am trying to populate a collection with data from a JSON file. I’m a backbone beginner, so my problems are probably easy to solve. But have struggled with this all day – so now I’m asking for guidance. I am creating a questionnaire, and want to load the questions from a JSON file stored […]

How can I enforce attribute types in a Backbone model?

I want to have a Backbone model with float attributes in it but without worrying too much about variable types. I would like to encapsulate the value parsing right there in the model so I am thinking of overriding the set function: var Place = Backbone.Model.extend({ set: function(attributes, options) { if (!_.isEmpty(attributes.latitude)){ attributes.latitude == parseFloat(attributes.latitude); […]

How to implement Oauth/OpenID/Custom authentication with Backbone.js/Javascript frontend?

I have a site and our backend and frontend ( 100% backbone) are decoupled RestFul (JSON + Ajax), and we are thinking about how to implement the user authentication now. We want to support facebook, Google and others (OAuth and OpenId) and also our custom method to users who don’t have or don’t want to […]

Avoid `fetch()` marking model attributes as changed

I’m using Backbone in a user settings profile form. I fetch the model and render its information into the form. When I save the model all the parameters are sent instead of the ones changed by the user. First I fetch the mode and render it on the view: // Fetch model and render on […]