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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:23:54+00:00 2026-06-07T23:23:54+00:00

I’ve got a LocalStore object for storing data locally. It’s based around a Lawnchair

  • 0

I’ve got a “LocalStore” object for storing data locally. It’s based around a Lawnchair object.

var LocalStore = function(name) {
    var that = this;
    that.name = name;

    that.lawnchair = Lawnchair({ name: that.name }, function(store) {
        this.before('save', function(record){
            console.log("saving " + that.name);
            console.log(record);
        });

        this.after('save', function(record){
            console.log("saved " + that.name);
            console.log(record);
            that.getData(function(records){
                console.log("now it's this");
                console.log(records);
            });
        });
    });

    that.getData = function(callback) {
        that.lawnchair.get(that.name, callback);
    };
};

LocalStore is then extended with _.extend(from the Underscore.js library) with this method:

save: function(collection, callback) {
        this.lawnchair.save({ key:this.name, value: collection }, function(record) {
            callback(record);
        });
    }

This code is used to update a Backbone.js Collection object to Lawnchair. The first time “save” runs for my Users Collection it saves correctly and shows that the object is a simple key/value pair where value is an Array.

Later in my code when a User selects a Default Project, I modify the Users Collection and call “save” again with an updated “defaultProjectId” on the User. The code runs error free, but the after('save') code for Lawnchair runs and shows me that:
– The record object returned is a key/value pair where value is a full Backbone.js Collection with the defaultProjectId property set correctly.
– The getData method that grabs the latest from the Database still shows as a key/value pair with value a simple Array and defaultProjectId is set incorrectly.

I’m at a loss as what to do. It should just be simply calling “lawnchair.save” updates the record, but it just doesn’t do it.

  • 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-07T23:23:56+00:00Added an answer on June 7, 2026 at 11:23 pm

    Could you try this jsfiddle?

    http://jsfiddle.net/QUgtg/1/

    I have recreated your code. Instead of a backbone collection, I am passing in an array of objects. This seems to work. You can see the logging output in Firebug.

    I have used my own extend code to add the save(). Though honestly, I don’t see why you would want to do it that way, instead of just adding a property to the prototype. Your code may differ in that aspect.

    If what I have posted works on your end, could you modify that code to show what are you doing differently? If possible, recreate the issue on jsfiddle…

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I have some data like this: 1 2 3 4 5 9 2 6
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.