Giter Site home page Giter Site logo

Comments (6)

pythoneer avatar pythoneer commented on June 25, 2024

ok i found a way to debug this

console.log("check");
console.log(typeof this);
console.log(typeof this.data);
console.log(typeof this.data.atts);
console.log(typeof this.data.atts.rendered);
if (typeof this.data.atts.rendered === 'function') {
  console.log("call rendered");
  this.data.atts.rendered(this.data.map);
} else { 
  console.log("rendered is undef"); 
}

this outputs

check
object
object
object
undefined
rendered is undef

ok i guess that was the wrong place to lock at?

from meteor-autoform-map.

pythoneer avatar pythoneer commented on June 25, 2024

Ah, now i am getting a feel of it whats happening. Your code gets never to the point (if clause) to call my callback function and pass the map as an argument. BUT somehow my callback is invoked anyway! I can choose any arbitrary property name for my callback function but its called anyway.

location: {
        type: String,
        autoform: {
            type: 'map',
            afFieldInput: {
                <left out>,
                absdfXXX: function (gmap) {
                    console.log("set current gmap");
                    console.log(gmap) ;
                    Session.set("currentGoogleMap", gmap);
                }
            }
        }
    },

So obviously i am doing something wrong but the fact that the functions is called anyway made me believe it was right in the first place.

EDIT:
if i log the this.data.atts its showing me, that whatever function name i set its undefined. But that function is called (but maybe erased after?)

EDIT2:
Ok now i am pretty much stuck. After all i would guess your code is right, in a sense that if it ever worked before.I would guess the error is in Autoform itself cuz i can never find a place in your code where the rendered (or whatever i named the function) is not undefined. I could only guess where the toplevel entrypoint of the values passed by Autoform is (either in Template.afMap.created or Template.afMap.rendered i would vote for the last cuz you starting to handle the data here) but all places i found rendered with a function undefined. Im starting to believe, that Autoform is messing this up and for whatever reason calling any function present and destroying it by setting it undefined.

EDIT3:
I havn't looked through the code of Autoform but i believe this is happening. If you set a property as function the function is invoked by Autoform and the returnvalue is saved into the property and passed by. Thats why every arbitrary named property with a function is called but undefined is left over – cuz my function did not return any value. If i do something like this:

location: {
    type: String,
    autoform: {
        type: 'map',
        afFieldInput: {
            <left out>,
            rendered: function () {
                return function(gmap) {
                    console.log("set current gmap");
                    console.log(gmap) ;
                    Session.set("currentGoogleMap", gmap);
                }
            }
        }
    }
}, 

it seems to work but i'll get this error message

Exception from Tracker recompute function:
RangeError: Maximum call stack size exceeded

from meteor-autoform-map.

mpowaga avatar mpowaga commented on June 25, 2024

Hmmm... really strange but I guess it's autoform messing up. It seems to work only when you put the rendered callback in afFieldInput and it will return the callback function, e.g.

location: {
  type: String,
  autoform: {
    type: 'map',
    afFieldInput: {
      rendered: function () {
        return function (map) {
          console.log(map);
        };
      }
    }
  }
}

from meteor-autoform-map.

pythoneer avatar pythoneer commented on June 25, 2024

Yes, as i mentioned in my last edit in my third post: if i do that i'll get an exception

Exception from Tracker recompute function:
RangeError: Maximum call stack size exceeded

obviously Autoform is trying to evaluate this recursively, no matter what, until the jsVM stack get overflown.

from meteor-autoform-map.

mpowaga avatar mpowaga commented on June 25, 2024

It may be caused by other property. For me it worked. At least on Chrome. I've came across this error on Firefox several times.

from meteor-autoform-map.

pythoneer avatar pythoneer commented on June 25, 2024

I tried it again and surprisingly the exception did not happen but the "outter" function is called 15 times. Regardless of this, you should consider to update your docs or investigating whats causing that quirk (API change of Autoform?) after this i would consider this issue closed.

from meteor-autoform-map.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.