Hi folks,
I have been programming a couple of SAPUI5 applications and one of the biggest 'frustrations' so far is that I am constantly running into duplicate ID issues as I tend to use JS views ...
Coming from a WebDynpro background where the framework handled the automatic lifecycle control (default) it is quite 'painfull' to somehow deal whith this yourself ...
Having said that ... I am not sure I understand why some of the following code does not seem to affect the DOM at all ...
view.removeAllContent();
view.destroyContent();
view.destroy();
jQuery.empty();
jQuery.remove();
I would imagine that the following piece of code would actually destroy all the elements of the main element on the page so I can happily recreate the same elements but nope ... still getting duplicate ID errors ...
// Let's find the element
var myDetailContainer = sap.ui.getCore().byId("contKSRD");
// If we have it
if ( typeof myDetailContainer != "undefined" ) {
// jQuery DOM remove ( not sure why we still need to do this )
$("#contKSRD").empty();
// SAPUI5 API remove
myDetailContainer.removeAllContent();
myDetailContainer.destroyContent();
myDetailContainer.destroy();
}
Overall I feel I am lacking a bit of a solid strategy on MVC and views rendering with lifecycle management ... A simple search view which would load a list of data with a table on it ... that means the view will be 'loaded' every time the user selects a list type ... once you load the same list twice ... bang ... duplicate ID's ( even assuming I added the list identifier as part of the ID ) ...
Thanks,
Steven