inline editing not submitting on pressing enter key

inline editing not submitting on pressing enter key

SaomairSaomair Posts: 2Questions: 1Answers: 0

hello
i am using chosen plugin and when i select anything from dropdown and click enter button its not submitting the data.
i have tried with select2 and selectize but its not submitting
note: it have just updated editor and its not working. it was working fine before update

Replies

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    Hi,

    What version of Editor were you using before please? Are you using 1.7.1 now?

    Do you have a link to the page that I can take a look at?

    Thanks,
    Allan

  • geometrygeometry Posts: 17Questions: 4Answers: 0

    I am having this problem as well. After upgrading to 1.7.0 and now 1.7.2 when using select2 as part of an inline edit it does not submit either on enter or on selection with the mouse. The drop down will close but sits active and I have to manually "blur" away with tab or mouse click on another field or elsewhere on the page for it to submit.

    Unfortunately I don't have a page to link you.

    Speaking of select2 field type plugin can you bring back a version number in the source? (I thought it used to display a version when it was part of the download builder?) This way we can know when it is updated

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    Better version control for the plug-ins is a good idea - thanks!

    Recently I added this to the Select2 integration:

        owns: function ( conf, node ) {
            if ( $(node).closest('.select2-container').length || $(node).closest('.select2').length || $(node).hasClass('select2-selection__choice__remove') ) {
                return true;
            }
            return false;
        }
    

    That is probably what is causing the problem. The reason that was added was to allow multiple items to be selected from Select2 when inline editing (previously it was blurring immediately when selecting an item).

    Could you confirm if that code is present in the Select2 Editor integration you are using? Could you also show me your Editor field configuration for the field? It might be that the above should only activate if Select2's multi-select / tags feature is enabled.

    Regards,
    Allan

  • geometrygeometry Posts: 17Questions: 4Answers: 0
    edited February 1

    Hi Allan,

    I have checked the version of the select2 plugin I was using and I am pretty sure it did not have the code you showed above. I tried updating to the latest select2 plugin code with no success

    My editor field configuration is pretty basic:

    { name: "typeId", type: "select2", options: types, opts: { placeholder: "Select Type...", allowClear: true } }
    

    The following code from the select2 plugin fires when a selection is made from the dropdown

    .on( 'select2:close', function () {
         open = false;
     } );
    

    but it seems like it never bubbles up to the editor itself as none of the editor events seem to go off e.g preBlur or close.

    I have tried restoring older versions of my code but still cannot get it to operate properly so I am thinking it must be something wrong in my teams code

    I will try to do some more debugging tomorrow and let you know if I find anything

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    I've just been looking into this as well, and Select2 with a single select behaves the same way as select: example.

    If you want to automatically submit when an item is selected, I think you'd need to add an event listener for that to call submit().

    Perhaps it should be that in inline mode, both the select and select2 field types should submit if there can only be one selection. Open to feedback on this!

    Allan

  • geometrygeometry Posts: 17Questions: 4Answers: 0

    Hmmm I could have sworn it was submitting before! I thought I was going mad but if this is how it has always been then maybe I am.

    The one difference with the ordinary select vs select2 is that when I hit enter on the field it submits but it doesn't appear to do that with select2? Maybe select2 is capturing the enter.

    I'd be all for that being the default. Or even a boolean option to turn it on and off?

    What is the best way to attach event listeners to the select2 created by the editor then without editing the select2 plugin?

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    The one difference with the ordinary select vs select2 is that when I hit enter on the field it submits

    That's interesting. What browser are you using? With Chrome the return key shows me the list (I would have sworn that it didn't before...!).

    What is the best way to attach event listeners to the select2 created by the editor then without editing the select2 plugin?

    Use editor.field( 'myFieldName' ).inst() to get the Select2 instance or field().input() to get the input element.

    Allan

  • geometrygeometry Posts: 17Questions: 4Answers: 0

    I am using Chrome (64.0.3282.140)...

    • With Select2 on Enter it opens the dropdown
    • With a regular select it submits the field (using the demo link you posted above)

    I think we can put this to rest now... I'll just have to accept that it probably was never submitting the field on selecting an option (even though I was so sure :smile:)

    Thanks heaps for your help

  • lokesh16lokesh16 Posts: 8Questions: 0Answers: 0
    edited February 13

    I am facing another scenario in connection with above discussion.

    In Editor Window if I Press Enter Key in "Select2" Field Type Control, the Editor Window gets Submitted.

    The formOptions:{main:{submitOnReturn:false}} is working fine for field type such as input field, textarea. However it does not seem to apply for Select2 control.

    How can I prevent / disable "submitOnReturn" for Select2 Control?

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    The plug-ins can have a canReturnSubmit function. For what you want you would have that function return false;.

    Allan

  • lokesh16lokesh16 Posts: 8Questions: 0Answers: 0

    Yes, that is exactly what I tried allan, and after incorporating canReturnSubmit in select2 plugin code, the code detects the event however for some reason, it still gets dismissed, It appeared like the canReturnSubmit code got detected after the Editor window dismissed. Something is overriding

  • lokesh16lokesh16 Posts: 8Questions: 0Answers: 0

    This is the code I had incorporated in canReturnSubmit in select2 plugin

    canReturnSubmit: function(conf,dt){
    return false;
    },

    Not sure what to assign for dt, which is supposed to represent the node upon which the return key was triggered.

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    I've just tried adding:

        canReturnSubmit: function(conf,dt){
            return false;
        }
    

    to my local Select2 demo and it appears to work okay (i.e. doesn't submit). I did initially have KeyTable enabled which caused issues (changing focus of the cells), but disabling that allows it to work okay.

    This is the configuration I was using for the field:

                {
                    label: "Site:",
                    name: "users.site",
                    type: "select2",
                    def: undefined
                }
    

    What options are you using yourself?

    Allan

  • lokesh16lokesh16 Posts: 8Questions: 0Answers: 0
    edited February 15

    allan, Thanks for trying and updating the status. I had also used similar options. After confirmation from your end I checked my code in detail.

    canReturnSubmit is working perfectly fine. Problem was elsewhere.

    Old Code
    < script >
    var editor;
    $(document).ready(function(){editor=new .........

    New Code
    < script >
    $(document).ready(function(){var editor=new .........


    By the way, allan, dataTables and Editor are simply awesome, it is beautiful. Special Thanks for you!

  • allanallan Posts: 48,281Questions: 1Answers: 6,967 Site admin

    Thank you :).

Sign In or Register to comment.