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

  • SEARCH
  • Home
  • 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 7759779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:42:55+00:00 2026-06-01T13:42:55+00:00

To learn backbone Im creating a Twitter like app. So you know that Twitter

  • 0

To learn backbone Im creating a Twitter like app. So you know that Twitter sends a GET request to the server every N seconds to check for new tweets. If there are new tweets, it creates the hidden li elements and shows the button with “N new Tweets”. If you click it, it shows the hidden li elements, showing the new tweets.
But the behaviour is different when you add a new tweet: the tweet is visible. You don’t have to click the button to see it.

I already have made the first part, for the hidden tweets. For the part of posting a new tweet and showing it direclty, I thought it would be easy to do by creating the new model, calling collection.create() and triggering the right event, something like:

var newTweet = new Tweet();
newTweet.set( /* set the attributes here. Some attributes are missing, because they are calculated server side */ );

var created_tweet = this.collection.create( newTweet, { silent: true, wait: true } ); // I choose silent=true because the add event on my collection is in charge of adding the new hidden tweets when there are new ones on the server
this.collection.trigger("posted_new_tweet", created_tweet);

Then, my collection is subscribed to the event “posted_new_tweet”, so every time a user posts a new tweet, a specific method of my collection is being called.
This approach was working fine until I got errors due to the variable created_comment passed in the trigger: it is not “complete”. I mean that the model has some attributes like “id” or *”created_on”* that are undefined. These attributes are calculated server side, but I thought that if I passed wait=true, it would wait and update my model with the response given by the server (when a POST request is made to the server, it returns the new created model in json)

Shouldn’t my model have the server side attributes aswell? Is it the right approach for such a thing? In case that it is not, how can I have 2 different methods to display a collection view?

Thank you!

  • 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-01T13:42:56+00:00Added an answer on June 1, 2026 at 1:42 pm

    create is still asynchronous even if you pass { wait: true }. The difference is without wait the model will get added to the collection immediately while with wait backbone won’t add it to the collection until a success response from the server.

    What you should do is add a success callback to create that fires the event upon the server response.

    var created_tweet = this.collection.create( newTweet, { silent: true, wait: true, success: this.successCallback } );
    
    // Add successCallback as a method to the collection
    successCallback: function(collection, response) {
      // I'm not 100% positive which values are passed to this function. Collection may actually be the new model.
      this.collection.trigger("posted_new_tweet", created_tweet);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have done my homework correctly, I have come to learn that Backbone
I've decided that I am going to try and learn backbone.js by making a
I'm just starting to get into backbone.js. It looks like it's pretty involved and
I'm creating a bare bones backbone example to try to learn it and am
Learn Twisted. I decided to write a server and client that once a second
I was trying to learn the ways of testing Backbone-based app using Jasmine. For
I would like to learn how to make image galleries and content sliders that
I would like to learn whether it is possible to get or listen running
I'm starting to learn Backbone with this simple example: <div id=counter>unkown</div> <button id=add-button>ADD</button> (function($){
I learn best by taking apart something that already does something and figuring out

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.