cancel
Showing results for 
Search instead for 
Did you mean: 

event in fragment not working

Former Member
0 Kudos

Hellos, i am doing a app sapui5 and i have a problem because i have done the fragment in which there is a event and this event is defined in the controller, so i did this:

controllerName="sacyr.controller.pendienteContabilizar" in the fragment but this not is working. If i put the fragment in the view directly, it is working goog. can somebody help me?.

Sorry for my english

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

thanks, but it yet not working, in the fragment i have this:

<core:FragmentDefinition xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns:commons="sap.ui.commons" controllerName="jas.controller.pendienteContabilizar"> <HBox > <VBox> </VBox> <VBox > <Label text="postright1"></Label> </VBox> <VBox> <Button icon="sap-icon://decline" press="eliminar" /> </VBox> </HBox> </core:FragmentDefinition>

and in the controller this is;

eliminar: function () { if (!this._oDialog) { this._oDialog = sap.ui.xmlfragment("sacyr.fragmento.selectext", this); this.getView().addDependent(this._oDialog); } return this._oDialog; },

i think the problem is that the fragment adds dinamic content

junwu
Active Contributor
0 Kudos

you have to assign the controller first. then you can use eliminar as event handler


Former Member
0 Kudos

Hi David,

Can you paste how you have called the above fragment.

<core:FragmentDefinition xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" 
xmlns:commons="sap.ui.commons" controllerName="jas.controller.pendienteContabilizar">
 <HBox > <VBox> </VBox> 
   <VBox > <Label text="postright1"></Label> 
  </VBox> 
  <VBox> 
   <Button icon="sap-icon://decline" press="eliminar" /> 
  </VBox> 
</HBox> 
</core:FragmentDefinition>

I think you are missing the 'this' keyword in the original fragment call as well.

junwu
Active Contributor
0 Kudos