Clear a single cell, with confirmation!
Clear a single cell, with confirmation!
Hey guys,
We recently added a way to clear a cell and it automatically submits it, well we want to avoid the auto submit and have a confirmation message appear before hand. Here is how we get it to clear the cells with an ugly dialog box.
[code]
$('#product-table').on('click', 'a.clearCell', function () {
var aData = $('#product-table').dataTable().fnGetData( $(this).parents('tr')[0] );
if (confirm('Are you sure you want to clear ' +aData['remainingRooms']+ ' rooms?')){`
editor.edit($(this).parents('tr')[0], null, null, false);
editor.set( 'remainingRooms', 0 );
editor.submit();
}
});
[/code]
We want to use the editor.message(); dialog to confirm they want to clear the cell instead of the ugly JavaScript box.
Thanks for the help!
We recently added a way to clear a cell and it automatically submits it, well we want to avoid the auto submit and have a confirmation message appear before hand. Here is how we get it to clear the cells with an ugly dialog box.
[code]
$('#product-table').on('click', 'a.clearCell', function () {
var aData = $('#product-table').dataTable().fnGetData( $(this).parents('tr')[0] );
if (confirm('Are you sure you want to clear ' +aData['remainingRooms']+ ' rooms?')){`
editor.edit($(this).parents('tr')[0], null, null, false);
editor.set( 'remainingRooms', 0 );
editor.submit();
}
});
[/code]
We want to use the editor.message(); dialog to confirm they want to clear the cell instead of the ugly JavaScript box.
Thanks for the help!
This discussion has been closed.
Replies
This is an interesting one! The Editor form is really only intended for one use at a time - and you've got an Edit form in it initially. You could use `message()` as you wish, but you'd need to reinitialise the Edit form after the confirmation. That would involve reading the value of each field in the form before the message and then restoring each value after the confirm. So it is possible, but not something that it was really designed for.
I'll have a think about what changes would be needed in Editor to make this use case a bit easier.
Regards,
Allan
To be honest we have brought editor outside of its comfort zone with this project we are on, we it is finished and released we will let you check it out for yourself! Thanks again Allan!
I really appreciate your feedback here, as this is something I would like to see added into a future release of Editor. I'm just sorry it doesn't provide this functionality for you already!
Regards,
Allan