简体   繁体   中英

x-editable + bootstrap 3 + Twitter typeahead.js not working

I tried to integrate Bootstrap3 with the awesome x-editable and typeahead.js, but I couldn't make it work:

I tried the following

  • mark the element with data-type='typeaheadjs'
  • add type='typeaheadjs' to $().editable()
  • move all parameters to data-* attributes
  • move all parameters to $().editable() arguments

but no luck.

HTML Code:

<div style="margin: 150px">
    <a href="#" id="username">Rome</a>
</div>

JS Code:

$('#username').editable({
    mode: 'inline',
    showbuttons: false,
    type: 'text',
    url: '/post',
    pk: 1,
    title: 'Enter an Italian city',
    typeahead: {
        local: ['Rome', 'Milan', 'Venice', 'Florence']
    }
});        

fiddle here: http://jsfiddle.net/Ggxbm/3/

even the provided example at http://vitalets.github.io/x-editable/docs.html#typeaheadjs does not work for me

What am I doing wrong?

You need to include typeahead.min.js AND typeaheadjs.js

as you can see in this fiddle http://jsfiddle.net/9q7Jd/1/ adding

http://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/inputs-ext/typeaheadjs/typeaheadjs.js

is fixing the issue.

you can found typeaheadjs.js in the zip archive in directory inputs-ext/typeaheadjs : https://github.com/vitalets/x-editable/tree/master/src/inputs-ext/typeaheadjs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM