Get Data From Removed Row
Get Data From Removed Row
Restful Web Services
Posts: 202Questions: 49Answers: 2
in Editor
I am trying to get some data from the 'postRemove' function after I have deleted a row using the 'Editor Remove' function. Ideally I would like the column 'monitor_id'.
I have tried this but I get nothing in my JSON string,
editor.on('postRemove', function(e, json, data) {
$(".refresh-after-ajax").load(window.location + "?delete=true" + " .refresh-after-ajax");
alert( 'json.cms_module_uptime_monitors.monitor_id' );
});
I am using a joined table.
What am I doing wrong?
Thanks
Chris
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi Chris,
The Editor libraries do't bother to return anything in the JSON data to the client-side after a remove since there is nothing needed (normally) there.
The documentation for
remove
andpostRemove
is actually wrong at the moment, there is nodata
parameter passed into the function. I've just updated this in the repo and will push it out to the site soon.Possibly the best option would be to listen for
preSubmit
and store theid
value submitted. Then you can use that inpostRemove
.Regards,
Allan
I am trying this,
But getting no response, is this not correct? In addition, could you point me in the direction of some documentation which details how to 'store' the id submitted and pass it to postRemove?
Many thanks
Remove the quotes - at the moment you are just alerting a string! You probably also need
data.data.cms_...
since that is how the data is structured in the submit.The best thing to do would be
console.log( data )
and having a look at the console in your browser to inspect the object.Allan
Oops - missed this bit:
That more of a general Javascript thing, so not something that is documented in the Editor docs:
Having said that, this isn't actually strict true as Editor doesn't submit any data other than the row id for delete (see the docs here).
When you noted that it was the id you wanted before I had assumed it was the main row id, not a child id - sorry.
In which case, what you need to do is something like:
That uses the DataTables API (
row().data()
) to get the data for the row in question andmodifier()
to find out what row is in question!Allan
Many thanks