Hello,
I have pages created with label "ESP". At some point I will want to archive the page. To do this I want to remove "ESP" and add "Archived".
Below is code that allows a new label to be added OK through my testing, but the removal does not work.
<!DOCTYPE html>
<html><head></head>
<body>
<button onclick="runScript()">Archive Project</button>
<p><div id="result"></div></p>
<script type="text/javascript">
function runScript() {
var archived = "archivedtest";
AJS.Labels.addLabel(archived, AJS.params.pageId, AJS.params.contentType);
var current = "esp";
var labels = $(".aui-label-split-main");
if( labels[i].innerHTML.search(current) == esp ) {
AJS.Labels.removeLabel( $(labels[i]), AJS.params.pageId, AJS.params.contentType);
}
};
</script>
</body></html>
Please can someone advise on what is wrong with the code and how I can remove "ESP" label?
Thanks!