Working example of jeditable and autocomplete working together

前端 未结 6 2262
无人共我
无人共我 2021-02-10 18:54

I see a lot of google posts on this but all seems to be talking about how this is in progress. Does anyone know of a working version of jeditable and autocomplete functionality

6条回答
  •  星月不相逢
    2021-02-10 19:37

    I had the need for the same functionality with jeditable and autocomplete from bassistance, for a list of emails separated by a comma. So, I changed the demo from Mika Tuupola and had it working like this:

    $.editable.addInputType('autocomplete', {
        element: $.editable.types.text.element,
        plugin: function(settings, original) {
            $('input', this).autocomplete(settings.autocomplete.urlOrData,
                settings.autocomplete.options);
        }
    });
    

    And when you call jEditable you need to add the following:

    $('.autocomplete').editable('http://www.example.com/save', {
        type: 'autocomplete',
        autocomplete: {
            urlOrData: ["Aberdeen", "Ada", "Adamsville"] , // can also be url: 'http://www.example.com/autocomplete',
            options: {
                multiple: true
            }
        }
    });
    

    The basic thing to understand here is that when you call $('input', this).autocomplete(...) you are actually applying the autocomplete plugin functionality to the editable input, and that's where you must pass the autocomplete options, via the settings object, which is the same as the settings you pass to jeditable.

提交回复
热议问题