diff options
Diffstat (limited to 'docs/jsapi/ui.js.html')
-rw-r--r-- | docs/jsapi/ui.js.html | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/docs/jsapi/ui.js.html b/docs/jsapi/ui.js.html index 015a955a2..f0f5bbda1 100644 --- a/docs/jsapi/ui.js.html +++ b/docs/jsapi/ui.js.html @@ -1048,6 +1048,8 @@ <li data-name="LuCI.ui#hideModal"><a href="LuCI.ui.html#hideModal">hideModal</a></li> + <li data-name="LuCI.ui#instantiateView"><a href="LuCI.ui.html#instantiateView">instantiateView</a></li> + <li data-name="LuCI.ui#itemlist"><a href="LuCI.ui.html#itemlist">itemlist</a></li> <li data-name="LuCI.ui#pingDevice"><a href="LuCI.ui.html#pingDevice">pingDevice</a></li> @@ -5970,6 +5972,38 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { }, this.varargs(arguments, 2, ctx)); }, + /** + * Load specified view class path and set it up. + * + * Transforms the given view path into a class name, requires it + * using [LuCI.require()]{@link LuCI#require} and asserts that the + * resulting class instance is a descendant of + * [LuCI.view]{@link LuCI.view}. + * + * By instantiating the view class, its corresponding contents are + * rendered and included into the view area. Any runtime errors are + * catched and rendered using [LuCI.error()]{@link LuCI#error}. + * + * @param {string} path + * The view path to render. + * + * @returns {Promise<LuCI.view>} + * Returns a promise resolving to the loaded view instance. + */ + instantiateView: function(path) { + var className = 'view.%s'.format(path.replace(/\//g, '.')); + + return L.require(className).then(function(view) { + if (!(view instanceof View)) + throw new TypeError('Loaded class %s is not a descendant of View'.format(className)); + + return view; + }).catch(function(err) { + dom.content(document.querySelector('#view'), null); + L.error(err); + }); + }, + AbstractElement: UIElement, /* Widgets */ @@ -5998,7 +6032,7 @@ return UI; <footer> - Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Apr 02 2020 21:30:57 GMT+0200 (Central European Summer Time) + Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Fri Apr 03 2020 13:28:08 GMT+0200 (Central European Summer Time) </footer> </div> </div> |