Clear a single cell, with confirmation!

Clear a single cell, with confirmation!

vmanvman Posts: 35Questions: 3Answers: 0
edited June 2013 in General
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!

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi,

    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
  • vmanvman Posts: 35Questions: 3Answers: 0
    Haha thank you, we tried the [code]message()[/code] method before and we didn't have much luck. We managed to do a simple jQuery alert, it is ugly but it does fine until we figure this out.

    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!
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Being on the edge and outside of the comfort zone is good! That's how progress is made.

    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
This discussion has been closed.