Hello,
I am looking for a way to get the number of labels from the current page that I have open in the editor.
This script runs when the editor is loaded:
// load editor first
AJS.bind("init.rte", function(){
var buttonID = "rte-button-publish";
//check if publish button exist
if(AJS.$("#" + buttonID).length > 0) {
//onClick
AJS.$("#" + buttonID).click(function (e) {
console.log("Clicked 'Publish' page button", this);
var labelbutton = "rte-button-labels";
// HOW DO I GET THE LABEL COUNT
if(AJS.$("#" + labelbutton).find(".trigger-text").text() == "Labels")
{
//show alert
alert("Please add at least one or more labels!");
console.log("Show Alert", this);
//Dont finish Action
e.preventDefault();
console.log("Default prevented", this);
e.stopPropagation();
console.log("Stoped Propagation", this);
}
});
}
});
Basically only the last the if statement in the code above doesn't work for me.
I need something like:
if (LABELCOUNT == 0) {DO THIS;}
I am thankful for every help!