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 8690323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:52:42+00:00 2026-06-12T23:52:42+00:00

I have an issue with a model, i instanciate it up with some default

  • 0

I have an issue with a model, i instanciate it up with some default values, i am using the set() method to change it, and when i use the fetch() méthod, i get the defaults values instead the new ones, i tried to log myModel.toJSON() in the console and i see the new values, i launch myModel.fetch() i get the defaults values on the server side, crazy no ?

Here is the model prototype:

window.User = Backbone.Model.extend({
    defaults : {
        id : "1",
        username : "anonymous",
        facebook_id : "1235486421",
        facebook_token : "AEZH93FZFEFSFSFS4545154sfsfSF"
    },
    urlRoot: 'http:/localhost:3000/user',
    initialize : function() {
        console.log('User Constructor...');
        this.url = "http://localhost:3000/user/"+this.get('username')+'/'+this.get('facebook_id')+'/'+this.get('facebook_token');
    }
});

Here is the chunck of code where i use fetch():

    fetch_user: function(){
    var CurrentUser = new User();
    FB.login(function(response) {
        if (response.authResponse) {
            var access_token = response.authResponse.accessToken;
            FB.api('/me', function(response) {
                console.log('Good to see you, ' + response.name + ', id: '+response.id+', token: '+access_token);
                CurrentUser.set('username', response.name);
                CurrentUser.set('facebook_id', response.id);
                CurrentUser.set('facebook_token', access_token);
                console.log('Current user is:  ' + CurrentUser.toJSON());
                CurrentUser.fetch({
                    success: function(_model){
                        console.log('User fetched successfully');
                    },
                    error: function(_model, error){
                        console.log('User fetched unsuccessfully');
                    }
                });
            });
        }
        else {
            console.log('User cancelled login or did not fully authorize.');
        }
    }, {scope: 'email'});
},

Thanks !

  • 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-12T23:52:43+00:00Added an answer on June 12, 2026 at 11:52 pm

    Since your URL scheme is not default “/object/id”, you should update URL:

    window.User = Backbone.Model.extend({
        defaults : {
            id : "1",
            username : "anonymous",
            facebook_id : "1235486421",
            facebook_token : "AEZH93FZFEFSFSFS4545154sfsfSF"
        }, events {
            "change" : "updateUrl"
        },
        initialize : function() {
            console.log('User Constructor...');
            this.updateUrl();
        },
        updateUrl : function() {
            this.url = "http://localhost:3000/user/" +
                       this.get('username') +
                       '/'+this.get('facebook_id') + 
                       '/'+this.get('facebook_token');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have issue, after checkout on checkout/onepage/success get a user info using order id,
I have some issue. I import django User model, create new user then trying
I have an issue with my model in EF model first. I have a
I have an issue with my view where on HTTP POST the view model
I have an issue with the CJuiAutoComplete in Yii and using it with a
I have an issue that has me stumped. We have a model assembly and
I have an issue using the protectedObservable custom binding below found at this link.
This jsFiddle highlights my issue. It is mimicking some functionality I have where an
I have a model Issue and a nested Model Relationship In the issue.rb I
I have a model Issue. Issues have Comments and Votes through join models. In

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.