Voyager: Deleting a Post always deletes the item of the first clicked delete button in the list

Created on 10 Feb 2017  路  5Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.3
  • Voyager Version: 0.10.13
  • PHP Version: 5.6

The JS in the browse.blade template replaces the __id string with the id of the item of the clicked delete button, if I click cancel, the delete_form action still contains the id of that item even if I click the delete button of an another item, the delete_form is still containing the old id and its action is not updated with the new id.

bug

All 5 comments

I'm assigning myself to this :D I'll send the commit later

Edit: sent #697

I added this as a temporary solution :D

$('button:contains("Cancel")').on('click', function () {
        window.location.reload();
});

Good luck.

This was fixed inside /tcg/voyager/resources/views/bread/browse.blade.php but wasn't copied to /resources/views/vendor/voyager/posts/browse.blade.php

Simply replace the click function in posts/browse.blade.php to:

$('td').on('click', '.delete', function (e){
    var form = $('#delete_form')[0];

    form.action = parseActionUrl(form.action, $(this).data('id'));

    $('#delete_modal').modal('show');
});

function parseActionUrl(action, id) {
    return action.match(/\/[0-9]+$/)
        ? action.replace(/([0-9]+$)/, id)
        : action + '/' + id;
}

I won't make a PR since, you have assigned it to yourself.

We are getting rid of those views (posts/* and users/*) in next version, so they use default BREAD views.
And the posts BREAD will probably be moved to a plugin/hook

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

craigb88 picture craigb88  路  3Comments

TXRRNT picture TXRRNT  路  3Comments

abacram picture abacram  路  3Comments

wislem picture wislem  路  3Comments

vaggelis2018 picture vaggelis2018  路  3Comments