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

Create method in mappings receive meaningless options.parent for observableArray properties #33

Closed
bikeshedder opened this issue Oct 8, 2011 · 3 comments

Comments

@bikeshedder
Copy link

When mapping arrays, options.parent is set to an observable containing an empty array regardless of the jsObject or target parameter. Normal properties receive the target model as options.parent.

It would be great if the create method would always receive the target model regardless of the type of property being mapped.

Use case: Mappings where access to the target model is required while mapping array elements.

@sagacity
Copy link
Collaborator

The update callback already receives the target, so you can specify that as a temporary workaround. The update callback is called immediately after the create, and also during any updates.

It should not be a problem to add the target to the create callback as well, though. I'll see what I can do.

@sagacity
Copy link
Collaborator

Could you maybe provide a jsfiddle that illustrates in more detail what you want to do (and how you would expect to be able to do it)?

@bikeshedder
Copy link
Author

http://jsfiddle.net/ZwhSV/1/

In order to see what is really happening you should put some console.log statements inside the create and update functions. You should easily see that the parent is always pointing to an empty array - regardless of the previous content of Bag.items.

I just opened issue #35 which is slightly related to this.

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

Successfully merging a pull request may close this issue.

2 participants