Skip to content

Commit

Permalink
Add dg.deleteForm() to delete a form from the DOM and memory
Browse files Browse the repository at this point in the history
  • Loading branch information
signalpoint committed Sep 7, 2022
1 parent 1ae8035 commit 53e66ef
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/includes/forms/form.inc.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,31 @@ dg.formExists = function(id) { return jDrupal.functionExists(id); };
dg.loadForm = function(id) { return dg.forms[id] ? dg.forms[id] : null; };

dg.loadForms = function() { return dg.forms; };

/**
* Deletes a form from memory.
* @param {type} id
*/
dg.removeForm = function(id) { delete dg.forms[id]; };

/**
* Deletes all forms from memory.
*/
dg.removeForms = function() { dg.forms = {}; };

/**
* Deletes a form from the DOM and from memory.
* @param {type} id
*/
dg.deleteForm = function(id) {
var form = dg.loadForm(id).form;
var domId = form._attributes.id;
var wrapper = dg.qs('#form-wrapper-' + domId);
var parent = wrapper.parentNode;
parent.removeChild(wrapper);
dg.removeForm(id);
};

/**
* Given a form id, this will return its form state.
* @param id {String} The form id.
Expand Down

0 comments on commit 53e66ef

Please sign in to comment.