{hero}

$.fn.dataTable.Editor.safeId()

Since: Editor 1.4

Create an easy to use DOM id from an input string.
Please note - this property requires the Editor extension for DataTables.

The full Editor reference documentation is available to registered users of Editor - the information shown below is a summary only. If you already have an Editor license please , alternatively an Editor license can be purchased on this site, or sign up for the free trial.

Description

Editor field types will typically use the field's name to assign a unique id to the field's input element (or whatever element happens to be used for the field) as this can be useful if you wish to use jQuery to select specific elements.

DOM ids can have any character in this as of HTML5 including .. While perfectly valid it can cause issues with using CSS selectors since the dot is a class name separator. Editor also uses the dot as an object separator just like Javascript and SQL.

For example consider #myField.name - this is an id selector of #myField with a class of name. The dot can be escaped in the selector but this can make selectors look messy and is confusing for developers new to escaping selectors. As a result Editor provides this method for plug-in developers to create easy to use ("safe") ids for their input elements.

The functionality of this method is simple to replace the dot with a dash (-).