Remove from DB but not page?

Remove from DB but not page?

jwellmajwellma Posts: 6Questions: 3Answers: 0

Hello,

I'm using a standalone editor and was wondering if there is a way to remove an entry from the database, but have it remain on the page.

The use case is similar to a "many to many" relationship where I'd like to show all options available as checkboxes. I've overcome the first hurdle of compound keys and needing put a special hash between the keys when manually specifying them for a data-editor-id attribute. This makes checking/unchecking the box create or remove an entry from the combined table, however I'm left with the default functionality of removing the item from the page (DOM) after it is deleted from the database. Is there a way to avoid that last part?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,873Questions: 1Answers: 10,528 Site admin
    Answer ✓

    There isn't a built in way to stop Editor from doing that, since I've assumed that the majority of the time when you delete something from the database, you'd want the client-side to reflect that.

    What you would need to do is modify the Editor source a little. This is the section in question:

        remove: function ( identifier, fields ) {
            // If there is an element with an ID property matching the identifier,
            // remove it
            $('[data-editor-id="'+identifier+'"]').remove();
        }
    

    Just comment out the remove line.

    Allan

  • jwellmajwellma Posts: 6Questions: 3Answers: 0

    Ah thank you very much, it would actually be just for this one relation that I'd need to remove that functionality, but I believe I can make something work here.

This discussion has been closed.