How to access instance of own field?

How to access instance of own field?

Mariusz GluglaMariusz Glugla Posts: 16Questions: 0Answers: 1
edited January 2019 in Editor

Hi
I was searching for answer without success, trying to read manual and guide:
https://editor.datatables.net/manual/development/field-types
but has stack.
I have own field type prepared based on above guide. Working fine, but I do not know how can I access my own instance from set(), get() etc field's functions? I have code doing some stuff preparing widget etc and in some cases I would like to fire error or put other information for user using build-in field attributes and functions.
Should I store reference to my object in global jscript scope? What is the proper way to use API functions provided by Editor on my own field instance?

Replies

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Store the instance into the conf object that is passed into each plug-in method. That conf object is unique to each field.

    You can see a basic example of that in this plug-in (and most of the others) where I use conf._input = $('<div id="'+id+'"></div>');.

    Allan

This discussion has been closed.