eLabSDK.Experiment.Section.Text

Functions

NameDescription
addContent(content)Add or update text content in this paragraph section.

This sets the text/HTML content for a paragraph (text) section in an experiment. The content
is saved immediately to the database via AJAX. Fires the onContentAdded event when the save
completes successfully. Use this to programmatically add or update text content in experiment
paragraph sections, such as from templates, automated workflows, or custom editors.

Events

addContent(content)

Add or update text content in this paragraph section.

This sets the text/HTML content for a paragraph (text) section in an experiment. The content
is saved immediately to the database via AJAX. Fires the onContentAdded event when the save
completes successfully. Use this to programmatically add or update text content in experiment
paragraph sections, such as from templates, automated workflows, or custom editors.

Kind: global function

ParamTypeDescription
contentstringThe text or HTML content to set for this section

Example

// Add content to a paragraph section
var experiment = new eLabSDK.Experiment({
  experimentID: 123,
  onLoaded: function() {
    var section = this.getSection(456);
    if (section instanceof eLabSDK.Experiment.Section.Text) {
      section.addContent('<h3>Experimental Procedure</h3><p>Step 1: Prepare samples...</p>');
      section.onContentAdded(function() {
        console.log('Content saved successfully');
      });
    }
  }
});

Example

// Create new text section and add content
var experiment = new eLabSDK.Experiment({
  experimentID: 789,
  onLoaded: function() {
    var exp = this;
    this.addSection({
      sectionHeader: 'Methods',
      sectionType: 'PARAGRAPH',
      onCreated: function() {
        var textSection = exp.getSection(this.options.sectionID);
        textSection.addContent(
          '<h4>Materials</h4>' +
          '<ul><li>Chemical A</li><li>Chemical B</li></ul>' +
          '<h4>Procedure</h4>' +
          '<p>Mix chemicals A and B...</p>'
        );
      }
    });
  }
});

Example

// Update existing content with callback
var experiment = new eLabSDK.Experiment({
  experimentID: 321,
  onLoaded: function() {
    var section = this.sections[0];
    if (section instanceof eLabSDK.Experiment.Section.Text) {
      section.onContentAdded(function() {
        console.log('Section updated');
        alert('Content saved successfully');
      });
      
      section.addContent('Updated experiment notes...');
    }
  }
});

"onParagraphContentAdded" (object)

Kind: event emitted

ParamType
objecteLabSDK.Experiment.Section.Text

Example

var content = "your-content-here";
     paragraphSection.onParagraphContentAdded(function(){
         alert('content added!');
     });
     paragraphSection.onParagraphContentAdded('your-content-here');

© 2023 eLabNext