Jquery Token Input - allowCustomEntry not working

2019-03-04 15:25发布

问题:

I am using Jquery Token Input version 1.6.0. I would like to be able to enter custom entries into the token-input, but everytime I do so the form submits (I type a custom word and hit enter). Here is my code (in coffeescript):

jQuery ->
    $('[id$=tag_list_tokens]').each ->
        el = $(this)
        el.tokenInput '/listings/tags.json',
            theme: 'facebook'
            minChars: 1
            allowCustomEntry: true
            preventDuplicates: true
            prePopulate: el.data('load')
            allowFreeTagging: false

Everything works fine except for the custom entries...any idea what I'm doing wrong?

回答1:

allowFreeTagging wasn't implemented by version 1.6.0. Download v1.6.1 from Github. (The TokenInput website is a few years out of date.)

I imagine you'll want to set allowFreeTagging:true as well, and scrap allowCustomEntry.