JavaScript API

Search:

Welcome

Login to contribute. Register if you haven't yet.

Need Support?

Search this site to find an answer. If you still need help, post a Question. Private or account-related support inquiries can be made at the Private Support forum.

JavaScript API Class: Comment

An instance of the Comment class represents one comment on a page. Comments can be accessed using the "comments" implicit object, which contains the comments for the current page in chronological order, or by using the comments property of a Page object.

Properties

Name  Type  Access
Description 
comment  String  read/write The content of the comment. 
date
Date
read
The date the comment was posted.  Current user's time zone is applied.
id
Number read
The ID number for this comment (IDs are sequential for each page.
page
String
read
The name of the page this comment is attached to.
sessionID
String
read
The session ID of the user that posted this comment.
user
String
read
The name of the user that posted this comment.

Functions

Name  Return Type
Description 
save()
none
Saves changes made to this comment. If the comment does not exist yet (id==0) then a new comment is created. 
toString()  String
Returns the equivalent of comment.comment.
destroy()
none
Permanently deletes this comment.

Example

// get the comments for the Home page
var comms = site.page("Home").comments;
// iterate through the array of comments returned
for (i in comms) {
    // get a comment from the array
    var comment = comms[i];
    // use various properties to create a descriptive string
    var s = "The comment '" + comment.comment + 
        "' was made on " + comment.date + " by " + comment.user + ".";
    // ... do something with s
} 

return to Java Script API