vendredi 17 mai 2019

Uncaught TypeError: this.transitionTo is not a function in route

I am trying to redirect my page to the homepage after I successfully delete the item but it is telling me transitonTo is not a function.

This is my code:

import Route from '@ember/routing/route';
import Ember from 'ember';
import { inject as service } from '@ember/service';

/**
 * @module lebtivity/routes/event
 */
export default Route.extend({
  /**
   * @type {Service}
   */
  api: service(),

  ajax: Ember.inject.service(),

  /**
   * @param {Object} params The parameters extracted from the URL.
   * @return {Promise<Object>}
   */
  model(params) {
    return this.get('api').request(`/events/${params.slug}`);
  },

  actions:{
    remove: function (model) {
        console.log(model.id);
        Ember.$.ajax({
               method: "DELETE",
               url: model.id,
               success: function(data)
               {
                 this.transitionTo('index');
               }
             })
    }
  }
});




Aucun commentaire:

Enregistrer un commentaire