Masked input jquery why when you enter text using the event lost the mask?

There is a masked input plugin for Jquery

$("input[type=text]").mask("+7(999)-999-99-99"); // Bingham plugin to all input fields

on the screen there are buttons
<button data-num="1">1</button>
<button data-num="2">2</button>

$("input[type=text]").val($("input[type=text]").val() + $(this).data("num")); // get the field value and add figure button

when you press the button the value of the input changes but lost the mask, prompt where to dig.

P. S: next time problems I will pour on jsfiddle:)
September 26th 19 at 11:46
1 answer
September 26th 19 at 11:48
After all, You forced me to do an example. OK.
As I expected, the thing is that the plugin catches keyboard events and react to them. If You simply insert data nothing happens. Can try to insert Your sample and press Enter the plugin works again.
So here's an example, maybe not very beautiful, but the solutions after you push the button this code fires an event of pressing the enter key.
Read carefully the documentation, it is taken into account, but I couldn't find. Maybe there is some refresh method.
You can also run the mask for a second time
But this option is even worse.

Find more questions by tags JavaScriptjQuery