简体   繁体   中英

loopj jQuery Tokeninput (tokenized autocomplete) - getting value

Edit: This appears to be a known issue in both accessing and removing items. The POST functionality (to provide a set of ids) also is no longer present.

I'm using jQueryUI on my page but haven't found an adaptation of the built-in autocomplete function which will tokenize results Facebook-style. There are a couple plugins built for this purpose and I'm using the loopj package to do this.

I've got it hooked up to my PHP datasource and can pull suggestions and set tokens - I'm just having a problem getting the all-up value from the input. My understanding is that it is exposed as a list of id's (id and name being the two elements transferred to it via JSON) pertaining to the selected tokens.

Calling the following should (I think) return the value:

var t = $('#tokenizedinputid').val();

...but it comes back undefined. Strangely, if I place this in the onAdd: parameter in initialization, it fires once upon page load and then not when tokens are added. However this example from the demo page fires correctly, upon token addition:

onAdd: function (item) {
  alert("Added " + item.name);
},

Is there a way to adapt the above snippet to expose all of the selected tokens? Perhaps using.each()?

Recently added was this patch :

var tokens = $('#tokens').tokenInput('get');

This will return all id/name pairs programatically.

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