Support

Account

Home Forums Backend Issues (wp-admin) select2_args

Solving

select2_args

  • So, according to this https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/. How does one do this actually? Anyone know? I am trying to figure out how to add a class to the select2-drop element. Not much information on the page about actually doing anything.

  • To answer my own question

    
    (function($){
      // make sure acf is loaded
      if (typeof acf.add_filter !== 'undefined') {
        // this basically adds the filter to all fields that use select2
        acf.add_filter('select2_args', function(args, element, settings) {
          // look at the current element
          // test for something in the fields we want to modify
          if (element.hasClass('glyphicons-select') ||
              element.hasClass('glyphicon_selector')) {
            // if it's our field add something to args
            args['dropdownCss']['font-family'] = 'Glyphicons Regular';
          }
          return args;
        });
      }
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘select2_args’ is closed to new replies.