Tet banner

Custom Fields
Support MB User Meta OSM Map with User Meta: Error: $address.autocomplete is not a function

  • Creator
  • #14475
    Resolved pluginoven

    When placing an address and osm map on a user profile, the Nominatum autocomplete is not working and the following error is being thrown:

    Uncaught TypeError: $address.autocomplete is not a function
        at OsmField.autocomplete (osm.js?ver=4.18.0:134)

    This error is not being thrown when the meta_box in included on a standard post_type.

    After inspecting the address field, there is a difference:
    Standard Edit Post:
    <input size="30" type="text" id="address" class="rwmb-text ui-autocomplete-input" name="addressx" autocomplete="off">
    Edit User Profile:
    <input size="30" type="text" id="address" class="rwmb-text" name="address">

    The issue can be easily recreated on a fresh WP install with meta-box and mb-user-meta:

    add_filter( 'rwmb_meta_boxes', 'register_user_meta_boxes' );
    function register_user_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
                'id'      => 'address_box',
                'title'     => __('Address'),
                'type'        => 'user',
                'context' => 'normal',
                'priority'    => 'high',
                'fields' => array(
                        'type' => 'text',
                        'name' => __('Address'),
                        'id'    => 'address',
                        'id'            => 'map',
                        'name'          => __('Location'),
                        'type'          => 'osm',
                        'address_field' => 'address',
                        'language'      => 'de',
                        'region'        => 'de',
        return $meta_boxes;

    I'll continue to troubleshoot, but though you guys should know about the issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #14479

    It seems that the jquery-ui-autocomplete scripts are not being enqueued with the osm field.
    Adding the following to public static function admin_enqueue_scripts located at inc/fields/osm.php seems to have resolved the issue.

    wp_enqueue_style( 'rwmb-autocomplete', RWMB_CSS_URL . 'autocomplete.css', '', RWMB_VER );
    wp_enqueue_script( 'rwmb-autocomplete', RWMB_JS_URL . 'autocomplete.js', array( 'jquery-ui-autocomplete' ), RWMB_VER, true );
    Anh Tran

    Thanks a lot for your feedback and help. Let's continue discussing this issue on your PR on Github.

    Update: it's resolved here.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.