The events-based customization in such case is not handy enough, as the inner API calls onSectionAdd
after the input is added and counted.
Also, the result of onSectionAdd
will be processed further, so the instant attempt to remove the input will cause an error. To avoid it in your implementation, it will be enough to delay the removing:
if (count >= 4){
webix.delay( webix.bind(function(){this.removeSection(i)}, this) )
}
However, I would suggest you to implement the required features as a custom multitect-based control with its own addSection
.
As this function uses private methods, you need to call the prototype function if an input should be added.
But also, you can modify the subConfig
and prevent further logic if needed.
Note that addSection
has to return a view/id of a view to which the focus can be set (according to the requirement of private API).
Please, check the following example: https://snippet.webix.com/o9eudtqr