onInit(): function{
this._oSelectedTrainingsModel = new sap.ui.model.json.JSONModel([]);
this.getView().setModel(this._oSelectedTrainingsModel, "selectedTrainings");
},
onAfterRendering: function() {
this.getView().byId("ViewSelectionButton").getBinding("text").attachChange(this._onTextUpdated, this);
},
In the XML view I have this binding:
<Button id="ViewSelectionButton"
class="magnificationPrep"
icon="sap-icon://cart-full"
tooltip="Share"
text="{i18n>viewTrainingsButton} ({= %{selectedTrainings>/}.length })"
press="handlePressViewSelection"
/>
At some point in the controller, an object is added to the _oSelectedTrainingsModel
:
this._oSelectedTrainingsModel.getProperty("/").push(oNewSelection);
At this point, the bound text property is changed and thus I'm expecting a call to the callback function _onTextUpdated
.
The model is empty, this is probably part of the issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…