Skip to content

JavaScript Bugg when sorting flexible groups #196

@richardsweeney

Description

@richardsweeney

What I expected

When sorting a group i got the following error in the console.

load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.6.1:2 Uncaught Error: Syntax error, unrecognized expression: #3]

The behaviour was sporadic. It worked occasionally.. (hate those bugs, sorry!). The sorting works now on master branch (when the JS works) and the correct section values are retained after save.

The page type class looks like this:

<?php

class Sections_Page_Type extends Papi_Page_Type {

/**
 * The type meta options.
 *
 * @return array
 */
public function meta() {
    return [
        'name'        => __( 'Sections Page Type', 'gram' ),
        'description' => __( 'The page type for building sections', 'gram' ),
        'post_type'   => 'page',
    ];
}

/**
 * @return array
 */
public function remove() {
    return [ 'editor', 'comments', 'thumbnail' ];
}

/**
 * Register the metabox
 */
public function register() {
    $this->box( __( 'Sections', 'gram' ), [ $this, 'render_sections' ] );
}

/**
 * @return array
 */
public function render_sections() {
    return [
        papi_property( [
            'title' => __( 'Sections', 'gram' ),
            'slug'  => 'page_sections',
            'type'  => 'flexible',
            'settings' => [
                'layout' => 'row',
                'items' => [
                    [
                        'title' => __( 'Wide image with text.', 'gram' ),
                        'items' => [
                            papi_property([
                                'title' => __( 'Wide Image', 'gram' ),
                                'type' => 'image',
                                'slug' => 'image',
                            ]),
                            papi_property([
                                'title' => __( 'Title', 'gram' ),
                                'type' => 'string',
                                'slug' => 'title',
                            ]),
                            papi_property([
                                'title' => __( 'Text', 'gram' ),
                                'type' => 'editor',
                                'slug' => 'text',
                                'settings' => [
                                    'media_buttons' => false,
                                    'drag_drop_upload' => false,
                                ],
                            ]),
                        ],
                    ],
                    [
                        'title' => __( 'Circlular image with text.', 'gram' ),
                        'items' => [
                            papi_property([
                                'title' => __( 'Title', 'gram' ),
                                'type' => 'string',
                                'slug' => 'title',
                            ]),
                            papi_property([
                                'title' => __( 'Text', 'gram' ),
                                'type' => 'editor',
                                'slug' => 'text',
                                'settings' => [
                                    'media_buttons' => false,
                                    'drag_drop_upload' => false,
                                ],
                            ]),
                            papi_property([
                                'title' => __( 'Image', 'gram' ),
                                'type' => 'image',
                                'slug' => 'image',
                            ]),
                            papi_property([
                                'title' => __( 'Alignment', 'gram' ),
                                'type' => 'dropdown',
                                'slug' => 'alignment',
                                'settings' => [
                                    'items' => [
                                        __( 'Image left, text right', 'gram' ) => 'img-left',
                                        __( 'Image right, text left', 'gram' ) => 'img-right',
                                    ],
                                ],
                            ]),
                        ],
                    ],
                ],
            ],
        ] )
    ];
}
}
  • Browser: Chrome
  • Papi: master branch on git
  • WordPress: 4.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions