Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Dojo widget "PostCreate" is called twice

$
0
0

I am making a very simple dojo widget that looks like this.

define([
    // Dojo"dojo/_base/declare",'dojo/dom','dojo/dom-construct',"dojo/text!./Templates/htmlpage.html",
    // Dijit"dijit/_TemplatedMixin","dijit/_WidgetBase",
    //CMS"epi-cms/_ContentContextMixin"],
    function (
    // Dojo
        declare,
        dom,
        domConstruct,
        template,
    // Dijit
        _TemplatedMixin,
        _WidgetBase,
    //CMS
    _ContentContextMixin) {
        return declare('namespace',
        [_WidgetBase, _TemplatedMixin, _ContentContextMixin], {
            templateString: template,
            postCreate: function () {
                this.inherited(arguments);
                var id = this._currentContext.id;
                id = parseInt(id.substring(0, id.indexOf('_')));
                var self = this;
                jQuery.ajax({
                    url: '/api/InfoScreenApi/GetParentSlides?id=' + id,
                    dataType: 'json',
                    success: function (data) {
                        var ulList = dom.byId('slideNamesList');
                        for (var i = 0; i < data.length; i++) {
                            domConstruct.place('<li>' + data[i] + '</li>', ulList);
                        }
                    }
                });
            },
            isValid: function () {
                return true;
            },
        })
    });

The problem I'm having is that this module seems to be called twice, making the list I am populating end up being twice the size with doublets.

The question is, is this normal behavior for the dojo widget or am I doing something wrong?  Thanks.


Viewing all articles
Browse latest Browse all 9076

Trending Articles