Try our conversational search powered by Generative AI!

How to translate helptext for custom property

Vote:
 

I have used PropertyStringList from AlloyTech template.

Now, bellow this property, it's written "Place items in separate lines".

How can I customize this per property? I have an ApiController for fetching custom translations, so I could just call the controller based on the property name. But, I don't have the reference to the name.

 

return declare("alloy.editors.StringList", [_Widget, _TemplatedMixin, _WidgetsInTemplateMixin, _CssStateMixin, _ValueRequiredMixin], {

        templateString: "<div class=\"dijitInline\">\
                            <div data-dojo-attach-point=\"stateNode, tooltipNode\">\
                                <div data-dojo-attach-point=\"textArea\" data-dojo-type=\"dijit.form.Textarea\" style=\"width: 300px\"></div>\
                            </div>\
                            <br />\
                            <span>${helptext}</span>\
                        </div>",

        baseClass: "epiStringList2",
                
        helptext: "Place items in separate lines",

...

    

What I basically want is just a possibility to call a function with property name. Any clues?

#73286
Jul 12, 2013 16:27
Vote:
 

Hi,

What I actually need is to be able to either:

- access $this.name in a function that I would call in helptext: function() { return giveMeTranslationForPageType(this.name); }, or

- declare var pageTypeName = someObject.name; above return declare("alloy.editors.StringList", ...., so that I can access it in helptext: function().

I am a backend developer, so pardon my lack of js knowledge :/

#73442
Jul 22, 2013 11:25
Vote:
 

Got it! Perhaps there is a nicer way (if so, let me know), but the problem is fixed by adding data-dojo-attach-point to a helptext span and setting its innertext in postCreate event.

templateString: "<div class=\"dijitInline\">\
                            <div data-dojo-attach-point=\"stateNode, tooltipNode\">\
                                <div data-dojo-attach-point=\"textArea\" data-dojo-type=\"dijit.form.Textarea\" style=\"width: 300px\"></div>\
                            </div>\
                            <br />\
                            <span data-dojo-attach-point=\"helpTextLabel\">${helptext}</span>\
                        </div>",

...
                
        helptext: "Separera objekt ovan genom radbrytningar",
...

        postCreate: function () {
            // call base implementation
            this.inherited(arguments);
...

            var translationUrl = '/api/translation/GetTranslationsOnDemand?id=' + this.name;
            var label = this.helpTextLabel;
            
            $.getJSON(translationUrl, function (data) {
                if (data != 'undefined') { label.innerHTML = data; }
            });
        },

    

 

#73488
Jul 24, 2013 10:25
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.