Try our conversational search powered by Generative AI!

Dojo widget "PostCreate" is called twice


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

    // Dojo
    // Dijit
    function (
    // Dojo
    // Dijit
    _ContentContextMixin) {
        return declare('namespace',
        [_WidgetBase, _TemplatedMixin, _ContentContextMixin], {
            templateString: template,
            postCreate: function () {
                var id =;
                id = parseInt(id.substring(0, id.indexOf('_')));

                var self = this;
                    url: '/api/InfoScreenApi/GetParentSlides?id=' + id,
                    dataType: 'json',
                    success: function (data) {
                        var ulList = dom.byId('slideNamesList');
                        for (var i = 0; i < data.length; i++) {
  • ' + data[i] + '
  • ', 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.

    Jan 11, 2016 12:30


    I that the event should be executed once per widget instance.

    If you used this widget twice as your property model editor then it will be executed twice.

    You could try to set breakpoint in postCreate method and see what is the property name: 

    If they are different, that it just simply means that those are different instances.

    Jan 11, 2016 13:49

    Hi and thanks for the answer.

    I have the instance once on this page. It should then be called once as you write. The weird thing is that the view, in this case a simple ul-list, is static, meaning that it is populated twice for the same

    property. See this image of the ul-list in the episerver form-editor. Each line is a li-node. It should only be two li-nodes.

    Even more strange (I think), the id of the property is "namespace_0" and "namespace_1". (couldn't find the metadata prop, used instead). This should mean it is different instances, but I can't see that there are two instances... I only call the page once.

    To make it work I can change the for-loop code to this. This way the element is populated only once.

    for (var i = 0; i < data.length; i++) {
                                self.slideNamesList.innerHTML += '<li>' + data[i] + '</li>'
                                //'<li>' + data[i] + '</li>', ulList);

    The commented is the old code. I don't understand anything :P

    Jan 11, 2016 14:10
    * You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.