How to pass an object to a widget constructor in DOJO javascript?

1

I'm trying to pass an object that I created as a parameter in the constructor of a widget. The object even goes and I can set my property with it, but as soon as it exits the builder it breaks.

Here is where I create the object and try to pass it as parameter to the constructor of my widget:

var mapa = new Mapa("mapa", "basemapGallery", "layerList");
var atualizaWidget = new AtualizaWidget(mapa);

This is the code of my Widget, it breaks well when it exits the constructor:

define([
    "dojo/_base/declare",
    "dojo/dom",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dojo/text!./widget/templates/AtualizaTemplate.html"

], function (declare, dom, _WidgetBase, _TemplatedMixin, template) {
    return declare([_WidgetBase, _TemplatedMixin], {
        objMapa: null,

        templateString: template,

        constructor: function (objMap) {
            this.objMapa = objMap;
        },

        //Ele quebra bem aqui quando sai

        postCreate: function () {
            //console.log(this.objMapa);
        }
    });

});

giving the following message:

  

TypeError: c is undefined ...] [a-zA-Z] * $ /. test (a)? a.toLowerCase (): a; c.tagName? l.set (c, b, : c.set (b, g); break; c ...

    
asked by anonymous 23.09.2016 / 21:21

1 answer

0

I ended up getting on trial and error. I do not know why that worked, but I had to pass the properties individually, thus:

var atualizaWidget = new AtualizaWidget({
    'mapa': mapa.mapa,
    'url': mapa.layerUrl
});

Anyway, thank you.

    
03.10.2016 / 20:46