Skip to content

JavaScript Bugg when sorting flexible groups #196

Closed

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

Activity

  1. frozzare commented on Oct 1, 2016

    @frozzare
    Member

    Thanks! Fixed in master branch.

  2. richardsweeney commented on Oct 1, 2016

    @richardsweeney
    Author

    Jösses vad du är snabb mannen!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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