2

I'm trying to get the shema title for the component using next javascript code:

var component = $models.getItem(id); component.getSchema().getTitle() component.getSchema().getInfo().Title;

the result of getSchema().getTitle() and getSchema().getInfo().Title is 'undefined'. What's wrong with my code? How can I get the component schema title?

  • These properties all load asynchronously, you need to add listeners to the "load" event. I'm sure there's examples on this site on how to do that. – Nuno Linhares Oct 17 '14 at 15:14
5

You need to use code like following

 var schema = $models.getItem(id).getSchema();
    var title;
    function loaded()
    {
        title = schema .getTitle();
    }
    $evt.addEventHandler(schema , "load", loaded);
    schema.load(true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.