Mjs.Dialogs.ConfirmDelete = {
open: function(model){
Mjs.Dialogs.ConfirmDelete._open(model);
},
_open: function(model) {
$( "#dialog-confirm-delete" )
.data('params', {model: model});
$( "#dialog-confirm-delete" ).dialog( "open" );
},
init: function() {
$( "#dialog-confirm-delete" ).dialog({
resizable: false,
autoOpen: false,
height:200,
modal: true,
buttons: {
"Delete": function() {
var model = $(this).data('params').model;
var element_id = model.domId();
var element = $('#'+ element_id);
console.log('trying to delete element id ' + element_id, element);
// If it's a codeline, remove all connections
// to/from this codeline
if (model instanceof Mjs.Models.Codeline ) {
Mjs.Collections.codelineCollection.remove(model);
} else { // if it's a connection just delete its endpoints
Mjs.Collections.connectorCollection.remove(model);
}
// Finally delete the element itself
element.remove();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}
};