Disable submit on enter press in input LS3

Plus d'informations
il y a 5 mois 4 jours - il y a 5 mois 4 jours #181639 par andrescevp
Hi people!

I has been crazy looking for a solution, but I can't...

Well, the thing is, that I have some selects that are handled by Select2.

It works, no problem.

I has been enabled the feature of tagging to can write free text, the point is that Select2 displys and searcher field to search options, when find your option then you can do click to select... or press enter (witch is the normal).

The problem is... when you press enter the form is submitted and do not want this.

Some way to prevent this?

I'm using limesurvey 3.

And yes, I check the workaround and was trying to do it myself... but I just can't find the proper way.

Thanks!
Dernière édition: il y a 5 mois 4 jours par andrescevp.

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 5 mois 4 jours #181644 par jelo

andrescevp écrit: Well, the thing is, that I have some selects that are handled by Select2.

You seem to use somekind of workaround. Select2 is what?

You should provide the exact version of LimeSurvey and the theme used for the survey.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 4 jours #181645 par andrescevp
LimerSurvey 3.1

Select2 is a library to dynamize select ( select2.org/ )

template vanilla

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 4 jours #181648 par andrescevp
I checked and doing this will remove the autosubmit on enter

ajaxHandler.unsetSubmit();

But keep doing validations and of course fail

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 3 jours #181652 par andrescevp
sadly was a fake hype hahaha

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 3 jours #181663 par DenisChenu
Maybe gitlab.com/SondagesPro/SurveyThemes/skel.../skelvanilla.js#L114

Because submit current form when using enter on a dropdown or a text input is the default behaviour of the browser.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 3 jours #181741 par andrescevp
thanks.

I notice that limesurvey is triggering the enter key twice...
                $(document).on('keypress keyup keydown', '#limesurvey input[type=text],#limesurvey input[type=search],#limesurvey select,#limesurvey .select2-results__option',function(e){
                    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
                    console.log(key);
                    if (key == 13 && e.ctrlKey != true ) {
                        cancelEvent(e);
                        var inputs = $(this).closest('form').find(':input:visible:enabled,select:visible:enabled,textarea:visible:enabled,button:visible:enabled');
                        if ((inputs.length-1) == inputs.index(this)) {
                            console.log('submit!');
                            $('.ls-move-submit-btn').focus();
                            return;
                        } else {
                            console.log('next!');
                            var nextElement = inputs.eq(inputs.index(this) + 1);
                            if ($(nextElement).data('select2')) {
                                $(nextElement).select2('open');
                                return false;
                            }
                            nextElement.focus();
                            return;
                        }
 
                        return false;
                    }
                });
 


console log:
index.php?r=survey/index&sid=939187:1441 100
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 97
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 115
index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 100
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 97
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 115
2index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 100
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 13
index.php?r=survey/index&sid=939187:1450 next!
index.php?r=survey/index&sid=939187:1441 13
index.php?r=survey/index&sid=939187:1446 submit!

some idea?

it do not stop the propagation... something to do with Pjax?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 3 jours #181743 par DenisChenu

andrescevp écrit: thanks.


it do not stop the propagation... something to do with Pjax?

I don't know … first things i do whan something don't work is disable ajaxMode (even if all work in fact …).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 3 jours #181746 par andrescevp
this did the trick. Thanks.

But anyway... weird bug.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 5 mois 2 jours #181771 par DenisChenu

andrescevp écrit: this did the trick. Thanks.

But anyway... weird bug.

bugs.limesurvey.org/view.php?id=14616 :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!