Hi All,
I have child views. In click event of child view, I have to call parent controller method which also send child view as parameter. How to do this.
In Parent View
I had following code
for(var j=0;j<oModel.oData.Groups[i].Products.length;j++)
{
var product = sap.ui.view({
viewName : "MyApp.product",
type : sap.ui.core.mvc.ViewType.JS
});//Created Child View
product.bindElement("/Groups/"+i+"/Products/"+j);
product.attachBrowserEvent("click", function(event){
oController.SelectionChange(event,product);
});//Child view click event
oLayout.addContent(product);
}
In Controller
SelectionChange: function(event, view)
{
//here 'view' is always last object in for loop above. But I want it should be that object which was clicked
if(view.IsSelected)
{
view.removeStyleClass("selected"); //Always remove last element style
}
else
{
view.addStyleClass("selected");//Always set last element style
}
}