Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Views Lifecycle management and duplicate ID's

$
0
0

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

 

 

     


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>