Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to append text to a specific html tag in a Confluence page

Daniel Baron March 31, 2018

I want to add a line of text after an html tag with the id skillLevel. I can find the id and get the text back but how to I actually update it? 

    var skillString = "<p> " + users_name + " - " + email + '</p>';
    var skillName = input.name;
    var skillLevel = input.value;	
    $.get('/rest/api/content?spaceKey=EXPERTISE&title=' + skillName + '&expand=space,body.storage,version,container', function (data, status) {
        var pageData = data.results[0];
	var existing_body = pageData.body.storage.value;  
        pageData.version.number += 1;
        var page_id = pageData.id;	  
	var target_bin = $(existing_body).find('#' + skillLevel);

// This will print out the text I want to add a line to.
alert(target_bind.text());
// Neither of these two ways to update seem to work.
//$('#'+skillLevel).append(skillString); //$(target_bin.text()).append(skillString); } $.ajax({ type: "PUT", url: "/rest/api/content/" + page_id, data: JSON.stringify(pageData), contentType: "application/json; charset=utf-8", success: function (data) { alert("Successfully added info"); } }); });

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events