How to pass an object to the javascript DOJO widget builder?

Asked

Viewed 40 times

1

I’m trying to pass an object I created as a parameter in the widget builder. The object even goes and I can set my property with it, but as soon as it leaves the Builder it breaks.

This is where I create the object and try to pass it as a parameter to my widget builder:

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

This is the code of my widget, it breaks well when you leave 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,g):c.set(b,g);break;c...

1 answer

0


I ended up getting it in trial and error. I don’t know why it worked like this, but I had to pass the properties individually, getting like this:

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

Anyway, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.