Dojo: load saved property value

Vote:
 

Hi,

I've created a custom property. After upgrade to EPiServer CMS 9.2+ (I don't remember which version), this.value inside postCreate function returns undefined.

This is the code:

define([
    "dojo/request/xhr",
    "dojo/json",
    "dojo/on",
    "dojo/html",
    "dojo/_base/declare",
    "dijit/_Widget",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "epi/i18n!epi/cms/nls/CustomProperties",
    "dojo/text!./template.html",
    "xstyle/css!./style.css"
],
function(
    xhr,
    json,
    on,
    html,
    declare,
    _Widget,
    _TemplatedMixin,
    _WidgetsInTemplateMixin,
    resources,
    template
) {
    return declare([_Widget, _TemplatedMixin, _WidgetsInTemplateMixin], {
        resources: resources,
        templateString: template,

        postCreate: function() {
            // returnes undefined
            console.log(this.value);

            ...
        }
    });
});

Everything works fine when I try to create a page / block that contains that property. But as soon as I press the publish button (or open one of the published pages / blocks that contain that property), this.value becomes undefined.

Property value is successfully saved in the database. I can access in it from the view by calling Model.Current.MyProperty.MyField, but it's always empty in the editor.

EPiServer 9.3.3.0

Any help would be greatly appreciated!

#141927
Nov 24, 2015 15:37
Vote:
 
#141935
Nov 24, 2015 16:26
Vote:
 

Hi,

What type do you store in the database? Is it a JSON serialized string? If you add a method called _setValueAttr like this, what result do you get in the console? Still undefined?

_setValueAttr: function(val) {
    this._set("value", val);

    window.console && console.log(val);
}

EDIT: I wrote this comment before I saw your answer.

#141936
Edited, Nov 24, 2015 16:31
Vote:
 

Yes, I'm storing a json serialized string.

Thanks for the help! :)

#141937
Nov 24, 2015 16:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.