Пытаюсь реализовать меню средствами библиотеки webix. Столкнулся с проблемой отображения view при нажатии на кнопку более двух раз.
Код основного меню index.js
function buildRoute(view) {
return function() {
webix.ready(function (){
webix.ui({id: 'root', rows: [view]}, $$('root'))
})
}
}
require(
[
'static/js/views/main.js',
'static/js/views/user/userList.js'
'util/resourceProxy',
],
function(main,users,products, categories,resourceProxy) {
webix.ready(function() {
webix.ui({
container: 'app',
rows: [
{
view: 'toolbar',
cols: [
{ view: 'button',value: 'Home',width: 100, align: 'center',click:function() {
routie('')
}},
{ view: 'button',value: 'User',width: 100, align: 'center',click:function() {
routie('users')
}},
]
},
{
id:'root'
}
]
})
})
routie({
'': buildRoute(main),
'users': buildRoute(users)
})
})
код userList.js
define(function() {
return {
rows: [
{
view: 'toolbar',
cols:
[
{
rows:[
{ view: "label", label: "Учетка"},
{ view:"text", id:"username", value:"Имя"},
{ view: "label", label: "Имя"},
{ view:"text", id:"name", value:"Имя"},
{ view: "label", label: "Фамилия"},
{ view:"text", id:"lastname", value:"Фамилия"},
]
},
{
rows:[
{ view: "label", label: "Активность учетки"},
{ view:"combo",
id:'active',
value:'true',
options:['true','false']
},
{ view: "label", label: "Email"},
{ view:"text", id:"email", value:"Почта"},
{ view: "label", label: "Пароль"},
{ view:"text", id:"password", value:"Пароль"},
]
},
{ view: "label", label: "Роль"},
{ view:"text", id:'role', value:'ROLE_CUSTOMER'},
{ view: "label", label: "Телефон"},
{ view:"text", id:"phone", value:"Телефон", format:{
parse: function(a){ return a.replace(/[^0-9]*/g,""); },
edit: function(a){
function chunk(a, n){
return a.length > n ? (a.substr(0,n) + "-" + chunk(a.substr(n), n)): a;
}
return (a.length ? "+": "") + chunk(a, 4);
},
}},
{ view:"button", value:"Добавить пользователя" ,click:function()
{
let data = {
'username': $$('username').getValue(),
'name': $$('name').getValue(),
'lastname': $$('lastname').getValue(),
'email':$$('email').getValue(),
'password':$$('password').getValue(),
'phone':$$('phone').getValue(),
'active':$$('active').getValue(),
'role':$$('role').getValue()};
$$(tableId).add(data);
}
},
]
},
{
id: tableId,
view: 'datatable',
columns:[
{id:'username', editor:'text' },
{id:'name', editor:'text' },
{id:'lastname', editor:'text' },
{id:'email', editor:'text'},
{id:'password', editor:'text'},
{id:'phone', editor:'text'},
{id:'active',
editor:"select",
value:'true',
options:['true','false']
},
{id:'role', template:'ROLE_CUSTOMER'},
{ id:"trash", header:"", template:"{common.trashIcon()}"}
],
url: 'resource->/api/user',
save: 'resource->/api/user',
autoheight: true,
autowidth: true,
editable: true,
pager: 'userID' + 'Pager',
datafetch: 10,
},
{
view: 'pager',
id: 'userID' + 'Pager',
size: 10,
group: 10,
template: '{common.first()}{common.prev()}{common.pages()}{common.next()}{common.last()}'
}
]
}
}
})
Ошибки
webix.js:12414 Uncaught TypeError: Cannot read property 'attachEvent' of null
at result._bind_collection (webix.js:12414)
at result._map_options (webix.js:12373)
at result._build_data_map (webix.js:12305)
at result._create_scheme_init (webix.js:12244)
at new result (webix.js:2170)
at Function._view (webix.js:2051)
at result._parse_cells (webix.js:21338)
at result._parse_cells (webix.js:21954)
at new result (webix.js:2170)
at Function._view (webix.js:2062)
_bind_collection @ webix.js:12414
_map_options @ webix.js:12373
_build_data_map @ webix.js:12305
_create_scheme_init @ webix.js:12244
result @ webix.js:2170
_view @ webix.js:2051
_parse_cells @ webix.js:21338
_parse_cells @ webix.js:21954
result @ webix.js:2170
_view @ webix.js:2062
_parse_cells @ webix.js:21338
_parse_cells @ webix.js:21954
result @ webix.js:2170
_view @ webix.js:2062
_ui_creator @ webix.js:1942
ui @ webix.js:1910
(anonymous) @ index.js:8
ready @ webix.js:3989
(anonymous) @ index.js:7
Routie.g.run @ routie.min.js:8
l @ routie.min.js:8
Routie.j.reload @ routie.min.js:8
hashchange (async)
(anonymous) @ routie.min.js:8
setTimeout (async)
Routie.j.navigate @ routie.min.js:8
j @ routie.min.js:8
click @ index.js:29
(anonymous) @ webix.js:2217
callEvent @ webix.js:482
callEvent @ webix.js:544
(anonymous) @ webix.js:4031
webix.js:12834 Uncaught TypeError: Cannot read property '$view' of undefined
at result.pager_setter (webix.js:12834)
at result.<anonymous> (webix.js:12795)
at webix.js:322