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

Model.destroy request params #428

Closed
whitecolor opened this Issue Jun 12, 2013 · 6 comments

Comments

Projects
None yet
3 participants
@whitecolor
Contributor

whitecolor commented Jun 12, 2013

Why not make possible to make destroy request with other params then just "id"?

destroy: 'DELETE /api/items/{some_other_id_attr}'
@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jun 12, 2013

Contributor

The placeholder {} should allow any model attribute. If it doesn't, could you make a quick Fiddle demonstrating what you are looking for?

Contributor

daffl commented Jun 12, 2013

The placeholder {} should allow any model attribute. If it doesn't, could you make a quick Fiddle demonstrating what you are looking for?

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Jun 12, 2013

Contributor

So what does that code mean in models.js?

            // `destroy` does not need data.
            if ( type == 'destroy' ) {
                args.shift();
            }
            // `update` and `destroy` need the `id`.
            if ( type !== 'create' ) {
                args.unshift(getId(self));
            }

In Ajax options generator function data contains only id, so any other params in {} are replaced with false.

Contributor

whitecolor commented Jun 12, 2013

So what does that code mean in models.js?

            // `destroy` does not need data.
            if ( type == 'destroy' ) {
                args.shift();
            }
            // `update` and `destroy` need the `id`.
            if ( type !== 'create' ) {
                args.unshift(getId(self));
            }

In Ajax options generator function data contains only id, so any other params in {} are replaced with false.

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Jun 12, 2013

Contributor

this code removes all data other than id

        destroy : {
            type : "delete",
            data : function(id){
                var args = {};
                args.id = args[this.id] = id;
                return args;
            }
        },
Contributor

whitecolor commented Jun 12, 2013

this code removes all data other than id

        destroy : {
            type : "delete",
            data : function(id){
                var args = {};
                args.id = args[this.id] = id;
                return args;
            }
        },
@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Jun 14, 2013

Contributor

so, will you consider this a bug or feature to add? Besides I don't know how to create fiddle that will show the behaviour. It blocks all ajax requests. But look at the code I supplied it is obvious.

Contributor

whitecolor commented Jun 14, 2013

so, will you consider this a bug or feature to add? Besides I don't know how to create fiddle that will show the behaviour. It blocks all ajax requests. But look at the code I supplied it is obvious.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jun 14, 2013

Contributor

I agree, it should allow all parameters.

Contributor

daffl commented Jun 14, 2013

I agree, it should allow all parameters.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Oct 14, 2013

Contributor

Fixed with #492.

Contributor

daffl commented Oct 14, 2013

Fixed with #492.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment