{"action":"opened","issue":{"url":"https://api.github.com/repos/TopShelfCraft/Shortlist/issues/28","repository_url":"https://api.github.com/repos/TopShelfCraft/Shortlist","labels_url":"https://api.github.com/repos/TopShelfCraft/Shortlist/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/TopShelfCraft/Shortlist/issues/28/comments","events_url":"https://api.github.com/repos/TopShelfCraft/Shortlist/issues/28/events","html_url":"https://github.com/TopShelfCraft/Shortlist/issues/28","id":364519554,"node_id":"MDU6SXNzdWUzNjQ1MTk1NTQ=","number":28,"title":"No JSON response for Item actions performed via Ajax","user":{"login":"martyspain","id":39329902,"node_id":"MDQ6VXNlcjM5MzI5OTAy","avatar_url":"https://avatars0.githubusercontent.com/u/39329902?v=4","gravatar_id":"","url":"https://api.github.com/users/martyspain","html_url":"https://github.com/martyspain","followers_url":"https://api.github.com/users/martyspain/followers","following_url":"https://api.github.com/users/martyspain/following{/other_user}","gists_url":"https://api.github.com/users/martyspain/gists{/gist_id}","starred_url":"https://api.github.com/users/martyspain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martyspain/subscriptions","organizations_url":"https://api.github.com/users/martyspain/orgs","repos_url":"https://api.github.com/users/martyspain/repos","events_url":"https://api.github.com/users/martyspain/events{/privacy}","received_events_url":"https://api.github.com/users/martyspain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-27T15:00:39Z","updated_at":"2018-09-27T15:00:39Z","closed_at":null,"author_association":"NONE","body":"The docs state that \"When actions are triggered via AJAX we return the result as a JSON array automatically.\" but this appears to only be true for List actions, not Item actions. \r\n\r\nThe `action` method for List actions in `services/Shortlist_ListService.php` returns a response array, but the `action` method for Item actions in `services/Shortlist_ItemService.php` sets `$this>response = $response` and then returns `true` rather than the `$response` variable itself. This means that any Item actions made via Ajax will not get a valid JSON response, but simply a Boolean value instead.\r\n\r\nI've modified the Item `actions` method on line 289 to return the `$response` variable in the same way that the List `actions` method does, and in conjunction with a minor tweak to the `controllers/Shortlist_ItemController.php` file to amend the `handleAction` method on line 71 to remove the conditional and simply perform the return method calls, this appears to solve the problem.\r\n\r\nAgain, almost certainly not a priority to be fixed but hopefully helpful for anyone else using Shortlist with Craft 2 and performing actions with Ajax."}}
{"actor":{"display_login":"martyspain"}}