I’m used to ExtJS and currently evaluate webix.js for a new project.
Since i’m trying to setup a webix-js app with MVV-pattern, i use requireJS to separate views from controls and make my code reusable.
That’s why i’m used to create the entire layout by framework and not to use any HTML-Target Containers. I also want to avoid using ids for my layout elements, because i want to be possible to create multiple instances of certains ui-elements without having to override any predefined ids.
My preferred way of creating a layout would be (see comments):
`
define('app/main', [
'webix',
'app/ui/table', // contains conf-obj for a table, no logic
'app/ui/form' // contains conf-obj for a form, no logic
], function (
webix,
tableConf,
formConf
) {
return function () {
/* create instances of form and table
* table and form receive autogenerated ids that I don't care about, because i have
* a reference to both instances
*/
var table = webix.ui(tableConf),
form = webix.ui(formConf);
/* create layout and embed instances */
return webix.ui({
id: 'main',
rows: [table, form] // THIS IS NOT WORKING, BUT I WISH IT DID
});
/* do any sort of logic/bindings etc.
*/
table.attachEvent('onSelectChange', function () { /* do something */});
}
});
/* launch app */
main();
`
But this is how I’m currently forced to do it.
`
define('app/main', [
'webix',
'app/ui/table', // contains conf-obj for a table, no logic
'app/ui/form' // contains conf-obj for a form, no logic
], function (
webix,
tableConf,
formConf
) {
return function () {
var layout, form, table;
/* create layout */
layout = webix.ui({
id: 'main',
rows: [tableConf, formConf] // THIS IS WORKING
});
/* form and table have autogenerated ids, that i don't know, i also don't have a reference
* tableConf.id and formConf.id are empty
*/
form = $$('main').$$('$form1'); // i need to guess the selector for the webix-obj-reference to my form
table = $$('main').$$('$table1');
/* do any sort of logic/bindings etc. */
table.attachEvent('onSelectChange', function () { /* do something */});
return layout;
}
});
/* launch app */
main();
`
I possibly just don’t get the concept of it, so please help. What’s the best webix-pattern of structuring an app?