Ember controller: nothing processed by action

I looked at related messages for several hours, but could not find the right answer to fix the problem I was facing.

I keep getting the error:

Unused error: nothing processed the "edit" action. If you performed an action, this error may be caused by the return of truth from the action handler in the controller, as a result of which the action will bubble.

I think the controller is malfunctioning, or is it bubbling up to the wrong route?

App.EventDetailsController = Ember.ObjectController.extend({ isEditing: false, actions: { edit: function() { this.set('isEditing', true); }, doneEditing: function() { this.set('isEditing', false); } } }); App = Ember.Application.create(); App.Router.map(function() { // put your routes here this.route('events', {path: '/events'}); this.route('createevent', {path: '/createevent'}); this.route('eventdetails', {path: ':eventdetails_id'}); }); App.EventsRoute = Ember.Route.extend({ model: function() { return events; } }); App.EventDetailsRoute = Ember.Route.extend({ model: function(params) { return events.findBy('id', params.eventdetails_id); } }); 

Does anyone know why this will not work?

+6
source share
3 answers

You probably want to define your routes as follows:

 App.Router.map(function() { this.resource('events', function() { // /events <-- your event listing this.resource('event', {path: ':event_id'}, function() { // /events/1 <-- your event details this.route('edit'); // /events/1/edit <-- edit an event }); this.route('create'); // /events/create <-- create your event }); }); 

But besides this, note that actions make their way through Routes, so try moving your action handler to EventDetailsRoute.

Read the part of the manual that talks about it here: http://emberjs.com/guides/templates/actions/#toc_action-bubbling

 App.EventDetailsRoute = Ember.Route.extend({ actions: { edit: function() { this.set('isEditing', true); }, doneEditing: function() { this.set('isEditing', false); }, //or maybe better: toggleEditing: function() { this.toggleProperty('isEditing'); } }, model: function(params) { return events.findBy('id', params.eventdetails_id); } }); 
+2
source

I have a suspicion that this is due to the fact that you are not using the correct naming conventions. If your route name is EventDetailsRoute , then the route must be specified in the router as event-details .

0
source

This problem occurs when our template and controller names are different. Check the template and controller name

0
source

Source: https://habr.com/ru/post/982969/


All Articles