javascript - SAPUI5: Compiling Declarative HTML is not working -
i saw code sinppet in sap documantion:
https://help.sap.com/saphelp_nw74/helpdata/en/91/f1454b6f4d1014b6dd926db0e91070/content.htm
i tried use in simple example below.
what error message in console:
uncaught typeerror: sap.ui.core.plugin.declarativesupport.compile not function
how solve it?
<!doctype html> <html> <title>declarative programming sapui5 - sample01</title> <script id='sap-ui-bootstrap' type='text/javascript' src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js' data-sap-ui-libs="sap.ui.commons" data-sap-ui-modules='sap.ui.core.plugin.declarativesupport' > </script> <script> function addbutton(){ console.log('addbutton'); $("body").append('<div id="button"><div data-sap-ui-type="sap.ui.commons.button" data-text="this button added dynamically"></div></div>'); sap.ui.core.plugin.declarativesupport.compile(document.getelementbyid("button")); } settimeout(addbutton,10); </script> </head> </html>
should work way:
<!doctype html> <html> <title>declarative programming sapui5 - sample01</title> <script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.ui.commons" data-sap-ui-modules="sap.ui.core.plugin.declarativesupport"> </script> <script> sap.ui.getcore().attachinit(function () { $("body").append('<div id="button"><div data-sap-ui-type="sap.ui.commons.button" data-text="this button added dynamically"></div></div>'); sap.ui.core.declarativesupport.compile(document.getelementbyid("button")); }); </script> </head> </html>
live example: https://jsbin.com/gegubuzuni/1/edit?html,output
Comments
Post a Comment