the-darc / angular-virtual-keyboard

An AngularJs Virtual Keyboard Interface based on GreyWyvern VKI

Home Page:http://the-darc.github.io/angular-virtual-keyboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

enterSubmit issues

blowsie opened this issue · comments

Great Plugin!

I noticed that enterSubmit does not submit my form.
Do you have a working example of this?

I'm doing something like this at the moment, It does not submit the form

HTML

<form ng-submit="login()">
<!--- Inputs --->
 <input                  type="password"
                             name="password"
                             data-ng-model="credentials.password"
                             ng-virtual-keyboard="{kt: 'numeric', enterSubmit:true}"
                             required="">
</form>

JS

 VKI_CONFIG.layout.numeric = {
          'name'   : 'numeric',
          'keys': [
            [['1', '1'], ['2', '2'], ['3', '3']],
            [['4', '4'], ['5', '5'], ['6', '6']],
            [['7', '7'], ['8', '8'], ['9', '9']],
            [['←', 'Bksp'], ['0', '0'], ['↵', 'Enter']]
          ]
        };

Looking at the plugin code, It seems there is nothing to transform the enterSubmit configuration do work with angular.

Ok so true did not work, but passing in the submit function without parenthesis works.

 ng-virtual-keyboard="{kt: 'numeric', enterSubmit:login}"

It is a bug in the vki-core.js#L591. Currently, when you use enterSubmit:true the directive calls the native browser HTMLFormElement.submit() function.

According to the method documentation:

The form's onsubmit event handler (for example, onsubmit="return false;") will not be triggered when invoking this method from Gecko-based applications. In general, it is not guaranteed to be invoked by HTML user agents.

And the Angular's ngSubmit directive works based on the form submit event. As result the enterSubmit vki's configuration will only work for the native form submition functionality and will not work for the Angular's ng-submit.

I think that use a callback method in the enterSubmit vki's configuration (like @blowsie suggested) is the better and simpler solution for this case.