datatracker/static/js/tokenized-field.js
Ole Laursen 8b63dd982f Add support for customizing max number of entries in EmailsField,
update to version 1.6 of jquery.tokeninput.js and fix problem with
reloading EmailsField pages by adding a data-pre attribute instead of
hacking the value attribute
 - Legacy-Id: 8264
2014-08-13 08:58:10 +00:00

20 lines
603 B
JavaScript

function setupTokenizedField(field) {
if (field.parents(".template").length > 0)
return; // don't tokenize hidden template snippets
var pre = [];
if (field.attr("data-pre"))
pre = JSON.parse((field.attr("data-pre") || "").replace(/"/g, '"'));
field.tokenInput(field.attr("data-ajax-url"), {
hintText: "",
preventDuplicates: true,
prePopulate: pre,
tokenLimit: field.attr("data-max-entries")
});
}
jQuery(function () {
jQuery(".tokenized-field").each(function () { setupTokenizedField(jQuery(this)); });
});