Search code examples
sapui5

What is the replacement for "metadataLoaded" in JSONModel?


In sap.ui.model.odata.v2.ODataModel, there is a metadataLoaded method which I can use it like this:

this.getModel().metadataLoaded().then( function() {
    var sObjectPath = this.getModel().createKey("/", {
        ID :  sObjectId
    });
    this._bindView("/" + sObjectPath);
}.bind(this));

JSONModel doesn't seem to have a corresponding method since there is no service metadata concept in client-side models. So is there any other work around?

I tried attachRequestCompleted. It's not working as expected:

function bindview() {
    that._bindView(sObjectId);
}
this.getModel().attachRequestCompleted(bindview);

Solution

  • As you rightly said, there is no metadata. But for Json model why do you want to wait for any event? You can directly bind the view.