Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toArray method not returning anything #25

Closed
rlustemberg opened this issue Jul 3, 2012 · 1 comment
Closed

toArray method not returning anything #25

rlustemberg opened this issue Jul 3, 2012 · 1 comment

Comments

@rlustemberg
Copy link

Hi Xavier:
Thanks a lot for the great work.
I was working with joli.js , and needed to retrieve the values of a record directly. I suppose we need to use the toArray method.
If that's the case I've noticed that you are initializing the return object as an array but assigning string keys to it. As a result the return value is an empty array.
Should it not be initialized as an object?
toArray: function() {
var result = {};

        joli.each(this._options.table.getColumns(), function(colType, colName) {
            result[colName] = this._data[colName];
        }, this);
        return result;
    }

instead of:
toArray: function() {
var result = [];

        joli.each(this._options.table.getColumns(), function(colType, colName) {
            result[colName] = this._data[colName];
        }, this);
        return result;
    }

I've changed that and I get the desired result (my desired result). Might I be breaking something?

@xavierlacot
Copy link
Owner

Thanks Richard :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants