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?

1
  • 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
    Commented Oct 17, 2014 at 15:14

1 Answer 1

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 and acknowledge you have read our privacy policy.

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