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

Accessing attributes in Model destroy #171

Closed
jej2003 opened this issue Nov 23, 2012 · 7 comments
Closed

Accessing attributes in Model destroy #171

jej2003 opened this issue Nov 23, 2012 · 7 comments
Milestone

Comments

@jej2003
Copy link

jej2003 commented Nov 23, 2012

Repost of https://github.com/bitovi/javascriptmvc/issues/32

Similar to this question:
http://forum.javascriptmvc.com/topic/destroy-method-signature-on-model?reply=true&remember=604800&securemode=false

I have a nested route in a rails app and need additional attributes of the model instance to form it correctly. Currently only ID is passed into Destroy.

Last word from Justin on that thread "I need to think about how to make something like this a little easier."

Any more thoughts on this? Would like to be able to refer to all attributes on model in destroy().

@jej2003
Copy link
Author

jej2003 commented Nov 24, 2012

In looking at Model.js am I wrong that this is just a change to lines 646 - 650 to do the following

return function( id, attrs, success, error ) {
    return ajax( str || this._shortName+"/{"+this.id+"}", addId(this, attrs, id), success, error, fixture(this, "Destroy", "-restDestroy"), "delete")
}

and then removing lines 142 - 144?

This worked for my case, but I am not sure if there is something else that will break because of this change.

@daffl
Copy link
Contributor

daffl commented Jan 11, 2013

Just to bump this up again, in current CanJS you should be able to compose the routes with any property like

destroy : "DELETE /todos/{messageId}/{id}"

With messageId being a property of your model. Is that what you need?

@jej2003
Copy link
Author

jej2003 commented Jan 23, 2013

Yes, this is exactly what I would need

@daffl
Copy link
Contributor

daffl commented Jan 23, 2013

Then give it a try with the latest CanJS version. We can close the issue if this works right? If it doesn't please let us know and we'll fix it.

@jej2003
Copy link
Author

jej2003 commented Jan 24, 2013

I unfortunately don't have the bandwidth to switch from JavaScriptMVC to CanJS (unless it's less complicated than I assume), If need be it's fine to mark this as fixed and I'll reopen the issue against CanJS when we move to it if it doesn't work.

@daffl daffl closed this as completed Jan 24, 2013
@daffl
Copy link
Contributor

daffl commented Jan 24, 2013

There is an upgrade path from JavaScriptMVC 3.2 to 3.3 which comes with CanJS. But if will require some changes if you want to do live-binding etc.

@jej2003
Copy link
Author

jej2003 commented Jan 24, 2013

Thanks daff, do you have a link to this? If so I'll check it out.

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

No branches or pull requests

2 participants