Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:25:01+00:00 2026-06-14T04:25:01+00:00

In my Backbone.js based app I am talking to my API that responds with

  • 0

In my Backbone.js based app I am talking to my API that responds with a 204 status and an empty body, in case a collection is requested which does not contain any data yet. That’s in my opinion how a RESTful API should respond in such case.

In my app now I have the problem, that obviously no event is triggered after a 204 response was received. I tried to bind reset and all like:

  FoosCollectionView.prototype.initialize = function() {
    this.collection = new FoosCollection;
    this.collection.bind('reset', this.render, this);
    this.collection.bind('all', this.render, this);
    return this.collection.fetch();
  };

but the events never fire. So I tried to give fetch some callbacks:

  FoosCollectionView.prototype.initialize = function() {
    this.collection = new FoosCollection();
    return this.collection.fetch({
      success: function(a, b, c) {
        debugger;
      },
      error: function(a, b, c) {
        debugger;
      },
      complete: function(a, b) {
        debugger;
      }
    });
  };

Same behaviour. No debug statement is ever reached in case the response is a 204. How can I handle 204 responses then? Will I have to dig down into sync and add an extra handling for 204 there or is there something in Backbone that I simply don’t know yet?

Thx Felix

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:25:02+00:00Added an answer on June 14, 2026 at 4:25 am

    The solution seems pretty forward and awkward at the same time:

    I simply define the parse method in my collections so that it checks, whether the passed response object is empty. That’s only the case when a 204 occured. Then inside parse I set this.collection.models = [] which triggers a reset event. The collections view is bound to that event, runs a function which can have a look inside this.collection.models. In case no models are given, a ‘no-content’ template can be rendered instead the standard template.

    If someone has a better approach, I’d appreciate to here that!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A Backbone app which I'm developing has a collection and a model, and associated
I have a Backbone.js application that allows users to create graphs based on large
I am attempting to create a Backbone.js view based on a Twitter bootstrap-modal, which
I have a project which is heavily JavaScript based (e.g. node.js, backbone.js, etc.). I'm
I'm building an app using Brunch and Backbone.js that is to include nested menus.
I'm writing a practice Backbone app, with Rails backend API, and I'm confused about
I was trying to learn the ways of testing Backbone-based app using Jasmine. For
I've been looking at some examples of backbone.js based application. I notice that in
We have a Backbone.js app that supports file uploads using plupload. The uploads are
I'm building a Backbone.js app with hash based navigation. It works fine everywhere except

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.