Skip to content

is there more clean way to implement transitionAfterSave? #29

Open

Description

@synthresin

in ember_data_example github source code. It use this approach

 transitionAfterSave: function() {
     // when creating new records, it's necessary to wait for the record to be assigned
     // an id before we can transition to its route (which depends on its id)
     if (this.get('content.id')) {
       this.transitionToRoute('contact', this.get('content'));
     }
 }.observes('content.id'),

It works fine, but maybe, this function will be executed whenever model's ID property is changed. I'm finding some more semantic way.

I want transition to be executed when the model's status is changed to 'isDirty' = false && 'isNew' == true form 'isDirty' = true, 'isNew' = false.

How can I implement this?

Activity

  1. dgeb commented on Feb 20, 2013

    @dgeb
    Owner

    It would be much preferable to monitor didCreate. However, the observer is an unfortunate hack around warp-drive-data/warp-drive#405

    The observer is only used to transition away after created records have been materialized. There's no danger of ids being changed (except from null -> server_assigned_id) in this application.

    I'll leave this issue open until we can remove this hack.

  2. tchak commented on Feb 22, 2013

    @tchak

    [edit] Nether mind, I though it was an ember issue

    github needs to be more clear in marking cross-project issue links...

  3. ZenCocoon commented on May 15, 2013

    @ZenCocoon

    As warp-drive-data/warp-drive#405 is now resolved, I think this could be updated and closed as well.

  4. sly7-7 commented on May 15, 2013

    @sly7-7
    Contributor

    @ZenCocoon you're right, we should now be able to put a listener on the didCreate event.

  5. lulezi commented on May 15, 2013

    @lulezi

    It looks like there are still issues: warp-drive-data/warp-drive#405 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions