TinyMCE:API/tinymce/create

From Moxiecode Documentation Wiki

Jump to: navigation, search

Contents

Method: create

Summary

Creates a class, subclass or static singleton. This method is used to create all classes within the TinyMCE API. This method enables you do OOP easy but powerful way.

Syntax

<void> create(<String> s, <Object> o)

Parameters

s
Class name, inheritage and prefix.
o
Collection of methods to add to the class.

Examples

// Creates a basic class
tinymce.create('tinymce.somepackage.SomeClass', {
   SomeClass : function() {
      // Class constructor
   },

   method : function() {
      // Some method
   }
});

// Creates a basic subclass class
tinymce.create('tinymce.somepackage.SomeSubClass:tinymce.somepackage.SomeClass', {
   SomeSubClass: function() {
      // Class constructor
      this.parent(); // Call parent constructor
   },

   method : function() {
      // Some method
      this.parent(); // Call parent method
   },

   'static' : {
      staticMethod : function() {
          // Static method
      }
   }
});

// Creates a singleton/static class
tinymce.create('static tinymce.somepackage.SomeSingletonClass', {
   method : function() {
      // Some method
   }
});
Personal tools