Standalone editor issue using remove()
Standalone editor issue using remove()
![mguinness](https://secure.gravatar.com/avatar/7e9057759b569a81fb7a90a9250cfb15/?default=https%3A%2F%2Fvanillicon.com%2F7e9057759b569a81fb7a90a9250cfb15_200.png&rating=g&size=120)
Having an issue when using editor remove() with Simple standalone editing. If the selector is keyless
then after the record is deleted you get the following client side exception: "Uncaught TypeError: K(...).remove is not a function"
Looking at the source code I think the problem is that the _htmlId
function returns the Root element when the identifier is keyless
. This means that the following editor function calls jQuery remove() on the root element which will fail.
remove: function (identifier, fields) {
// If there is an element with an ID property matching the identifier,
// remove it
_htmlId(identifier).remove();
}
Is there a way to include a check on the returned element before calling remove()?
This question has an accepted answers - jump to answer
Answers
I was able to modify the code to prevent the error:
Also I added the following to the remove function:
Can these changes be merged into your codebase?
If an item is keyless, it wasn't really designed to be deleted - only edited. Can you give me an over view of how you are using Editor in this context, for removing something that doesn't have a primary key value?
Allan
It's for a system settings table to archive the record. I understand it's probably an edge case, but not throwing an exception would be desirable. Hopefully you can add the check so I won't need to apply this to each new release of Editor. If I can override this function that would be fine, but I don't think that is possible?
Committed now - they'll be in Editor 2.1.1, which should drop next week.
The only tweak I've made is in the
remove()
method is to check that it is in standalone mode before using thekeyless
string:Thanks!
Allan
Thank you Allan, have a great weekend!