Scope or this .transitionToRoute

Hi, I have a modal dialog that opens up, after making changes and clicking save, its saving but not refreshing the data on the parent page, any help please?

        setViolationInactive: function () {
            var scope = this;


            let model = this.get('model');
            console.log('model 001');

            //validating form
            if ($("#edit-violationinactive-form").validate()) {
                var data = {
                    ViolationId: this.get('model.ViolationId'),
                    ResultId: this.get('content.ResultId'),
                    InactiveComment: this.get('inactiveComment'),

                scope.api('InspectionItem/SetViolationInactiveResult').post(data).then(function (response) {
                    toastr.success("Violation set Inactive.");
                }, function (error) {
                    toastr.error("Error saving violation inactive.");
            else {
                toastr.warning("Please fix the form", "Validation failed");

I’m trying to make sense of this to offer a helpful suggestion, but there’s just not enough detail.

1 Like

Sure can you please ask me what information can I provide more? Because I gave what possibly I can - thank you so much for your help my friend

Where does this code live? Is it in a controller? What is the this? What is this.api?

When you say it’s “not refreshing the data on the parent page”, what do you mean by “parent page”? Is it a different route that you’re returning to? Is it a parent route that is staying on the screen the whole time?

Are you using ember-data?

What is model? What is result and result.details? What is refreshData()?

In case it’s not clear, the reason I need to ask so many questions is that the code you shared is not idiomatic Ember code.

Yes thank you for asking, yes this code lives in a controller of a hbs, this.api is javascript call to the backend. Its a single page Ember application, violation.hbs opens up as modal popup from resultdetails page which is an another hbs, when we save the information of the violation.hbs modal dialog, I want to show the changed values on the resultdetails.hbs which is parent of the violation.hbs in this context.

What can I do for it? Would refreshing the resultdetails page works? That’s what I was trying to do, but if any better approach is there, please advice me.

The data that you’re changing and want to see re-rendered:

  • what is it?
  • how does it load? (in a route? somewhere else?)
  • where does it live? (a property on a controller? a component? a service?)
  • how do you change it when the user interacts with the modal?