Namespace: fieldType

Ancestry: Editor » .models. » fieldType

DataTables Editor v1.2.4 documentation

Navigation

Hiding private elements (toggle)
Showing extended elements (toggle)

Model object for input types which are available to fields (assigned to Editor.fieldTypes). Any plug-ins which add additional input types to Editor must implement the methods in this object (dummy functions are given in the model so they can be used as defaults if extending this object).

All functions in the model are executed in the Editor's instance scope, so you have full access to the settings object and the API methods if required.

Example

   // Add a simple text input (the 'text' type that is built into Editor
   // does this, so you wouldn't implement this exactly as show, but it
   // it is a good example.

   var Editor = $.fn.Editor;

   Editor.fieldTypes.myInput = $.extend( true, {}, Editor.models.type, {
     "create": function ( conf ) {
       // We store the 'input' element in the configuration object so
       // we can easily access it again in future.
       conf._input = document.createElement('input');
       conf._input.id = conf.id;
       return conf._input;
     },
   
     "get": function ( conf ) {
       return conf._input.value;
     },
   
     "set": function ( conf, val ) {
       conf._input.value = val;
     },
   
     "enable": function ( conf ) {
       conf._input.disabled = false;
     },
   
     "disable": function ( conf ) {
       conf._input.disabled = true;
     }
   } );

Summary

Methods - static

<static> create(conf) → {element|null}

Create the field - this is called when the field is added to the form. Note that this is called at initialisation time, or when the Editor#add API method is called, not when the form is displayed. If you need to know when the form is shown, you can use the API to listen for the onOpen event.

<static> disable(conf)

Disable the field - i.e. disallow user interface

<static> enable(conf)

Enable the field - i.e. allow user interface

<static> get(conf) → {*}

Get the value from the field

<static> set(conf, val)

Set the value for a field

Details

Methods - static

<static> create(conf) → {element|null}

Create the field - this is called when the field is added to the form. Note that this is called at initialisation time, or when the Editor#add API method is called, not when the form is displayed. If you need to know when the form is shown, you can use the API to listen for the onOpen event.

Parameters:
Name Type Attributes Default Description
1
confobject

The configuration object for the field in question: Editor.models.field.

Returns:

The input element (or a wrapping element if a more complex input is required) or null if nothing is to be added to the DOM for this input type.

<static> disable(conf)

Disable the field - i.e. disallow user interface

Parameters:
Name Type Attributes Default Description
1
confobject

The configuration object for the field in question: Editor.models.field.

<static> enable(conf)

Enable the field - i.e. allow user interface

Parameters:
Name Type Attributes Default Description
1
confobject

The configuration object for the field in question: Editor.models.field.

<static> get(conf) → {*}

Get the value from the field

Parameters:
Name Type Attributes Default Description
1
confobject

The configuration object for the field in question: Editor.models.field.

Returns:

The value from the field - the exact value will depend on the formatting required by the input type control.

<static> set(conf, val)

Set the value for a field

Parameters:
Name Type Attributes Default Description
1
confobject

The configuration object for the field in question: Editor.models.field.

2
val*

The value to set the field to - the exact value will depend on the formatting required by the input type control.