getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

"this.load is not a function" in custom section #4016

Closed hdodov closed 2 years ago

hdodov commented 2 years ago

I have a custom section in my kirby-git plugin. Since the latest version of Kirby, I get the following error:

this.load is not a function

I tested on the latest version of the plainkit using the exact same code from the extensions documentation about sections:

Kirby::plugin('yourname/modified', [
  'sections' => [
    'modified' => [
      'props' => [
        'headline' => function (string $headline) {
          return $headline;
        },
      ],
      'computed' => [
        'text' => function () {
          return 'The page has been modified at ' . $this->model()->modified('d.m.Y H:i:s');
        }
      ]
    ]
  ]
]);
panel.plugin("yourname/modified", {
  sections: {
    modified: {
      data: function () {
        return {
          headline: null,
          text: null,
        };
      },
      created: function () {
        this.load().then((response) => {
          this.headline = response.headline;
          this.text = response.text;
        });
      },
      template: `
        <section class="k-modified-section">
          <k-headline>{{ headline }}</k-headline>
          <k-text>{{ text }}</k-text>
        </section>
      `,
    },
  },
});

I get the same error:

localhost_plainkit_panel_site

Your setup

Kirby Version
3.6.1

distantnative commented 2 years ago

Trying to fix it over here https://github.com/getkirby/kirby/pull/4009

If you would like to test if that solves it.

hdodov commented 2 years ago

How should I test it? Do I just have to build the panel JS at the commit you've made and drop it in my plugin setup?

distantnative commented 2 years ago

Have a look at the comments, I posted the new panel/dist folder in there. You should replace that and clear the media/panel folder iy you would like to test it.

bastianallgeier commented 2 years ago