Caret Position

Adds Caret Position to GP Advanced Select fields.

The Caret Position is a built in plugin of Tom Select.

Instructions

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/

Code

Filename: gpadvs-caret-position.js

/**
 * Gravity Perks // Advanced Select // Caret Position
 * https://gravitywiz.com/documentation/gravity-forms-advanced-select/
 *
 * Adds Caret Position to GP Advanced Select fields.
 * 
 * The Caret Position is a built in plugin of Tom Select.
 * @reference https://tom-select.js.org/plugins/caret-position/
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */
window.gform.addFilter(
    'gpadvs_settings',
    function(settings, gpadvsInstance, selectNamespace) {
        /**
         * Scope to only multiselect fields.
         */
        if (gpadvsInstance.fieldType === 'multiselect') {
            settings.plugins.caret_position = {
                title: 'Caret Position',
            };
            settings.plugins.input_autogrow = {
                title: 'Input Autogrow',
            };
        }

        return settings;
    }
);

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.