I have a view with tiles, each of which have an id="foo"
property, and a press property pointing to a function in the controller.
The problem is I can get the id of the tile, but it is appended automatically to the view name, __xmlview1--foo1
. This can change if other views have already been created; there's no guarantee it will always be xmlview1, it could be xmlview2 or any higher number.
How do I retrieve the pure id as it appears in the tile's id property? Is this switch statement the best way to perform navigation, or is there a more robust/elegant solution?
onPress: function(oEvent){
switch(oEvent.getSource().sId) {
case "__xmlview1--foo1":
this.oRouter.navTo("myview1");
break;
case "__xmlview1--foo2":
this.oRouter.navTo("myview2");
break;
case "__xmlview1--foo3":
this.oRouter.navTo("myview3");
break;
case "__xmlview1--foo4":
this.oRouter.navTo("myview4");
break;
case "__xmlview1--foo5":
this.oRouter.navTo("myview5");
break;
default:
console.log("No match found.");
}