Layout callback not working?

Posted on
  • Somehow, "cb:" on buttons does not work for me. When i run the code example from the tutorial, i get

    Uncaught Error: Function "a" not found!
     at line 1 col 1
    a(this._l,b)
       ^
    in function called from system
    
    

    I tried 2v14 as well as the bleeding edge build. Funny thing is, about 5% of the time it works as expected, but usually not. I also get this error message when uploading via the Web IDE:

    Error parsing JavaScript, but uploading anyway.
    SyntaxError: Identifier 'a' has already been declared (1:1920)
    

    This is the code:

    var Layout = require("Layout");
    var layout = new Layout( {
      type:"v", c: [
        {type:"txt", font:"6x8:2", label:"A Test", id:"label"},
        {type:"btn", font:"6x8:2", label:"One", cb: l=>setLabel("One") },
        {type:"btn", font:"6x8:2", label:"Two", cb: l=>setLabel("Two") }
      ]
    });
    
    function setLabel(x) {
      layout.label.label = x;
      layout.render();
    }
    g.clear();
    layout.render();
    
  • That looks like it's caused by variable mangling: in the IDE settings, under Minification -> Esprima: Mangle, is "Shorten variable names" enabled? If so: try diabling it.

  • That's an odd one. Looks like it's caused by the standard offline minifier trying to minify Layout.js

    Try it now - I made sure that the Web IDE will load a pre-minified Layout library that should work ok

  • is "Shorten variable names" enabled? If so: try diabling it.

    That worked, thanks a lot!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Layout callback not working?

Posted by Avatar for RaoulDuke @RaoulDuke

Actions