Announcement

Collapse
No announcement yet.

How to rewrite super.data() in AMD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to rewrite super.data() in AMD

    I am following the directions shown here to modify the date type. The original view has this code:
    Code:
    data() {
      const data = super.data();​
    That syntax only works in ES6, which is not valid for customizations in the custom folder. AMD must be used. How do I rewrite that statement in AMD?

    Code:
    SyntaxError: 'super' keyword unexpected here (at date.js?r=1723651316:132:20)
        at new Function (<anonymous>)
        at Object._execute (loader.js:311:17)
        at Object._handleResponseText (loader.js:964:22)
        at loader.js:925:30​

  • #2
    It should work if you use ES6 classes (rather than the 'extend' method).

    Comment


    • #3
      Code:
      define(['views/fields/base'], Dep => {
          return class extends Dep {
              data() {
                 return {
                     ...super.data(),
                     newKey: 'value',
                 };
              }
          }​​
      });

      Comment


      • #4
        Thank you. That worked.

        Comment

        Working...
        X