<NME> jquery.flexdatalist.min.js
<BEF> !function(e){"use strict";e.fn.flexdatalist=function(t){var i=e(document),a=this;return this._keyNum=function(e){return e.which||e.keyCode},i.data("flexdatalist")||e(document).mouseup(function(t){var i=e(".flexdatalist-results"),a=i.data("target");a&&a.is(":focus")||i.is(t.target)||0!==i.has(t.target).length||i.remove()}).keydown(function(t){var i=e(".flexdatalist-results"),r=i.find("li"),s=r.filter(".active"),n=s.index(),l=r.length,o=a._keyNum(t);0!==l&&(13===o?(t.preventDefault(),s.click()):40!==o&&38!==o||(t.preventDefault(),40===o?s=l>n&&s.nextAll(".item").first().length>0?s.removeClass("active").nextAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:first").addClass("active"):38===o&&(s=n>0&&s.prevAll(".item").first().length>0?s.removeClass("active").prevAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:last").addClass("active")),a._scrollTo(i,s)))}).data("flexdatalist",!0),this._scrollTo=function(e,t){var i=(0===t.prev().length?t:t.prev()).position().top;e.animate({scrollTop:i+e.scrollTop()},100)},this._isEmpty=function(t){return a._isDefined(t)?null===t?!0:t===!0?!1:0===this._length(t)?!0:""===e.trim(t):!0},this._isObject=function(e){return e&&"object"==typeof e},this._length=function(e){return this._isObject(e)?Object.keys(e).length:"number"==typeof e.length?e.length:0},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this.each(function(){var i=e(this),r={},s="";i.attr("name");if(i.destroy=function(){i.removeClass("flexdatalist-set").off().val("").attr("type","text").next(".flexdatalist-alias, ul.flexdatalist-multiple").remove()},i.reset=function(){i.destroy()},("string"!=typeof t||(i[t](),"destroy"!==t))&&!i.hasClass("flexdatalist-set")){var n=e.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:!1,cache:!0,minLength:2,groupBy:!1,selectionRequired:!1,focusFirstResult:!1,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:!1,searchEqual:!1,normalizeString:null,maxShownResults:100},t,i.data());n.searchIn="string"==typeof n.searchIn?n.searchIn.split(","):n.searchIn,n.visibleProperties=0===n.visibleProperties.length?n.searchIn:n.visibleProperties,n.textProperty=null===n.textProperty?n.searchIn[0]:n.textProperty,n.multiple=i.attr("multiple"),n.relatives=n.relatives&&e(n.relatives).length>0?e(n.relatives):null;var l=i.clone(!1).attr({list:null,name:null}).addClass("flexdatalist-alias").removeClass("flexdatalist");if(n.multiple){var o=e("<ul>").addClass("flexdatalist-multiple").css({"background-color":i.css("background-color"),"border-color":i.css("border-left-color"),"border-width":i.css("border-left-width"),"border-style":i.css("border-left-style"),"border-radius":i.css("border-top-left-radius")}).insertAfter(i);e('<li class="input-container">').addClass("flexdatalist-multiple-value").append(l).appendTo(o)}else l.insertAfter(i);i.addClass("flexdatalist").attr("type","hidden"),i._init=function(){l.on("input keydown",function(e){var t=i._keyword();188===a._keyNum(e)&&!n.selectionRequired&&n.multiple&&(e.preventDefault(),i._value(t),i._removeResults())}).on("input keyup",function(e){if(i._changed()&&13!==a._keyNum(e)){var t=i._keyword();t.length>=n.minLength?i._search(function(e){i._showResults(e)}):i._removeResults(),n.multiple||(n.selectionRequired?0!==t.length&&i._selected()||i._value(""):i._value(t))}s=i._keyword()}).focus(function(){0===n.minLength&&(""===i._keyword()?i._data(function(e){i._showResults(e)}):l.trigger("keyup"))}).blur(function(){n.selectionRequired&&!i._selected()&&i._value("")}).attr("autocomplete","off"),i.addClass("flexdatalist-set"),window.onresize=function(){i._position()}},i._changed=function(){return s!==i._keyword()},i._chained=function(){if(n.relatives&&n.chainedRelatives){var t=function(t){n.relatives.each(function(){var r=a._isEmpty(e(this).val()),s=a._isEmpty(i.val());l.prop("disabled",r),t||!r&&s||(i._value(""),l.val(""),n.multiple&&o.find("li .remove").click())})};n.relatives.on("change",function(){t(),r={}}),t(!0)}},i._initValue=function(){var e=i.attr("value");a._isEmpty(e)||i._parseValue(e,function(e){a._isEmpty(e)||(i.val(""),i._values(e)),s=i._keyword()})},i._parseValue=function(e,t){if(i._toJSON())try{t(JSON.parse(e))}catch(a){}else if(i._toCSV()||"string"==typeof n.valueProperty){var r=e.split(",");if("string"==typeof n.valueProperty){var s=n.searchIn;n.searchIn=n.valueProperty.split(","),n.searchEqual=!0,i._search(function(e,i){i.length>0&&t(i),n.searchIn=s,n.searchEqual=!1},r)}else t(r)}else t(e)},i._data=function(t){if(a._isObject(n.data)&&!a._isEmpty(n.data))return void t(n.data);if("string"==typeof n.data)n.url=n.data;else if(a._isEmpty(n.url)&&a._isEmpty(n.data))return;var r=i._keyword(),s=r.substring(0,n.minLength),l=i._cache(s);return l?void t(l):void(i.hasClass("flexdatalist-loading")||(i.addClass("flexdatalist-loading"),e.ajax({url:n.url,data:e.extend(i._relativesData(),n.params,{keyword:r,contain:n.searchContain,selected:i.val()}),type:"post",dataType:"json",success:function(e){i.removeClass("flexdatalist-loading");var r=e.results?e.results:e;"string"==typeof r&&0===r.indexOf("[{")&&(r=JSON.parse(r)),a._isObject(r)&&(t(r),"string"==typeof n.data?n.data=r:a._isEmpty(n.url)||a._isEmpty(r)||i._cache(s,r))}})))},i._relativesData=function(){var t={};return n.relatives&&(t.relatives={},n.relatives.each(function(){var i=e(this);t.relatives[i.attr("name")]=i.val()})),t},i._datalist=function(){var t=i.attr("list");return a._isEmpty(t)||(n.data=[],e("#"+t).find("option").each(function(){var t=e(this).val();n.data.push({label:t,value:t})})),i},i._cache=function(e,t){if(n.cache){if(e=i._normalizeString(e),!a._isDefined(t))return a._isDefined(r,e)&&(t=r[e]),t;r[e]=t}return null},i._search=function(e,t){i._data(function(r){var s=[],l=[];a._isDefined(t)||(t=i._keyword()),"string"==typeof t&&(t=[t]);for(var o=n.groupBy,u=0;u<t.length;u++)for(var c=t[u],d=0;d<r.length;d++){var f=i._matches(r[d],c);if(f)if(l.push(f),o){if(a._isDefined(f,o)){var p=f[o];a._isDefined(s,p)||(s[p]=[]),s[p].push(f)}}else s.push(f)}e(s,l)})},i._matches=function(e,t){for(var r=!1,s=0;s<n.searchIn.length;s++){var l=n.searchIn[s];if(a._isDefined(e,l)){var o=e[l];i._find(t,o,e)&&(e[l+"_highlight"]=i._highlight(t,o),r=!0)}}return r?e:null},i._highlight=function(e,t){return t.replace(new RegExp(e,n.searchContain?"ig":"i"),'<span class="highlight">$&</span>')},i._find=function(e,t){return t=i._normalizeString(t),e=i._normalizeString(e),n.searchEqual?t==e:n.searchContain?t.indexOf(e)>=0:0===t.indexOf(e)},i._showResults=function(t){i._removeResults();var a=i._getResultsContainer();i._selected()&&i._selected(!1)._value(""),n.groupBy?Object.keys(t).forEach(function(r){var s=t[r],l=n.groupBy,o=i._getHighlight(s[0],l,r);e("<li>").addClass("group").append(e("<span>").addClass("group-name").html(o)).append(e("<span>").addClass("group-item-count").text(" "+s.length)).appendTo(a);i._items(s,a)}):i._items(t,a);var r=a.find("li:not(.group)");r.on("click",function(){var t=e(this).data("item");t&&(i._selected(!0)._removeResults()._value(t),i.trigger("select:flexdatalist",[t,n]))}).hover(function(){r.removeClass("active"),e(this).addClass("active")},function(){e(this).removeClass("active")}),n.focusFirstResult&&r.filter(":first").addClass("active"),i._position()},i._getResultsContainer=function(){var t=i;n.multiple&&(t=o);var a=e("ul.flexdatalist-results");return 0===a.length&&(a=e("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":t.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":t.css("border-bottom-left-radius"),"border-bottom-right-radius":t.css("border-bottom-right-radius")}).data("target",l)),a},i._items=function(e,t){for(var a=n.maxShownResults,r=0;r<e.length&&!(a>0&&a===r);r++)i._item(e[r]).appendTo(t)},i._item=function(t){for(var r=e("<li>").data("item",t).addClass("item"),s=0;s<n.visibleProperties.length;s++){var l=n.visibleProperties[s];if((!n.groupBy||n.groupBy!==l)&&a._isDefined(t,l)){var o={};if("thumb"===l)o=e("<img>").addClass("item item-"+l).attr("src",t[l]);else{var u=i._getHighlight(t,l);o=e("<span>").addClass("item item-"+l).html(u+" ")}o.appendTo(r)}}return r},i._removeResults=function(){return e("ul.flexdatalist-results").remove(),i},i._selected=function(e){var t="flexdatalist-selected";return a._isDefined(e)?(e?i.addClass(t):i.removeClass(t),i):i.hasClass(t)},i._values=function(t){return e.isArray(t)&&!a._isEmpty(t)?void e.each(t,function(e,t){i._value(t)}):void i._value(t)},i._value=function(t){var a=i._getText(t),r=i._getValue(t);if(n.multiple){if(""===t)return i;l.val("");var u=e("<li>").addClass("value").append('<span class="text">'+a+"</span>").append('<span class="fdl-remove">&times;</span>').insertBefore(o.find("li.input-container"));u.find("span.fdl-remove").click(function(){var t=e(this).parent();if(i._toJSON()||i._toCSV()){var a=i._inputValue();a.splice(t.index(),1),i._inputValue(a)}t.remove()})}else a&&a!==l.val()&&l.val(a);return i._inputValue(r,a),s=i._keyword(),i},i._inputValue=function(e,t){var r=i._toJSON(),s=i._toCSV();return a._isDefined(e)?(a._isObject(e)&&(r&&!a._isEmpty(e)?e=JSON.stringify(e):s&&(e=e.join(","))),i.val(e),i.trigger("change:flexdatalist",[e,t,n]).trigger("change"),e):(e=i.val(),e?r?e=JSON.parse(e):s&&(e=e.split(",")):(r||s)&&(e=[]),e)},i._getText=function(e){var t=e;return a._isObject(e)&&(t=e[n.searchIn[0]],t=a._isDefined(e,n.textProperty)?e[n.textProperty]:i._replacePlaceholders(e,n.textProperty,t)),t},i._getValue=function(t){var r=t;if(a._isObject(t))if(r=t[n.searchIn[0]],"*"===n.valueProperty)r=t;else if(a._isDefined(t,n.valueProperty))r=t[n.valueProperty];else if(i._toJSON()){var r={},s=n.valueProperty,l=n.textProperty;if(l){var o=l;"string"==typeof l&&(o=i._parsePlaceholders(l)),a._isObject(o)&&e.each(o,function(e,t){s.push(t)})}else a._isDefined(t,l)&&s.push(l);e.each(s,function(e,i){a._isDefined(t,i)&&(r[i]=t[i])})}if(n.multiple&&(i._toJSON()||i._toCSV())){var u=i._inputValue();!a._isEmpty(r)&&a._isObject(u)&&(u.push(r),r=u)}return r},i._replacePlaceholders=function(t,r,s){if(a._isObject(t)&&"string"==typeof r){var n=i._parsePlaceholders(r);if(!a._isEmpty(t)&&n)return e.each(n,function(e,i){a._isDefined(t,i)&&(r=r.replace(e,t[i]))}),r}return s},i._parsePlaceholders=function(e){var t=e.match(/\{.+?\}/g);if(t){var i={};return t.map(function(e){i[e]=e.slice(1,-1)}),i}return!1},i._normalizeString=function(e){return"string"==typeof e?("function"==typeof n.normalizeString&&(e=n.normalizeString(e)),e.toUpperCase()):e},i._keyword=function(){return l.val().replace(/^\s+/,"")},i._toJSON=function(){return a._isObject(n.valueProperty)||"*"===n.valueProperty},i._toCSV=function(){return!i._toJSON()&&n.multiple},i._getHighlight=function(e,t,i){return a._isDefined(e,t+"_highlight")?e[t+"_highlight"]:a._isDefined(e,t)?e[t]:i},i._position=function(){var t=l;n.multiple&&(t=o),e("ul.flexdatalist-results").css({width:t.outerWidth()+"px",top:t.offset().top+t.outerHeight()+"px",left:t.offset().left+"px","z-index":t.css("z-index")+1})},i._datalist(),i._init(),i._initValue(),i._chained(),s=i._keyword()}})},e("input.flexdatalist").flexdatalist()}(jQuery);
//# sourceMappingURL=jquery.flexdatalist.min.js.map
<MSG> allowing to add/change option(s) after input instance initialization

<DFF> @@ -1,1 +1,1 @@
-!function(e){"use strict";e.fn.flexdatalist=function(t){var i=e(document),a=this;return this._keyNum=function(e){return e.which||e.keyCode},i.data("flexdatalist")||e(document).mouseup(function(t){var i=e(".flexdatalist-results"),a=i.data("target");a&&a.is(":focus")||i.is(t.target)||0!==i.has(t.target).length||i.remove()}).keydown(function(t){var i=e(".flexdatalist-results"),r=i.find("li"),s=r.filter(".active"),n=s.index(),l=r.length,o=a._keyNum(t);0!==l&&(13===o?(t.preventDefault(),s.click()):40!==o&&38!==o||(t.preventDefault(),40===o?s=l>n&&s.nextAll(".item").first().length>0?s.removeClass("active").nextAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:first").addClass("active"):38===o&&(s=n>0&&s.prevAll(".item").first().length>0?s.removeClass("active").prevAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:last").addClass("active")),a._scrollTo(i,s)))}).data("flexdatalist",!0),this._scrollTo=function(e,t){var i=(0===t.prev().length?t:t.prev()).position().top;e.animate({scrollTop:i+e.scrollTop()},100)},this._isEmpty=function(t){return a._isDefined(t)?null===t?!0:t===!0?!1:0===this._length(t)?!0:""===e.trim(t):!0},this._isObject=function(e){return e&&"object"==typeof e},this._length=function(e){return this._isObject(e)?Object.keys(e).length:"number"==typeof e.length?e.length:0},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this.each(function(){var i=e(this),r={},s="";i.attr("name");if(i.destroy=function(){i.removeClass("flexdatalist-set").off().val("").attr("type","text").next(".flexdatalist-alias, ul.flexdatalist-multiple").remove()},i.reset=function(){i.destroy()},("string"!=typeof t||(i[t](),"destroy"!==t))&&!i.hasClass("flexdatalist-set")){var n=e.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:!1,cache:!0,minLength:2,groupBy:!1,selectionRequired:!1,focusFirstResult:!1,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:!1,searchEqual:!1,normalizeString:null,maxShownResults:100},t,i.data());n.searchIn="string"==typeof n.searchIn?n.searchIn.split(","):n.searchIn,n.visibleProperties=0===n.visibleProperties.length?n.searchIn:n.visibleProperties,n.textProperty=null===n.textProperty?n.searchIn[0]:n.textProperty,n.multiple=i.attr("multiple"),n.relatives=n.relatives&&e(n.relatives).length>0?e(n.relatives):null;var l=i.clone(!1).attr({list:null,name:null}).addClass("flexdatalist-alias").removeClass("flexdatalist");if(n.multiple){var o=e("<ul>").addClass("flexdatalist-multiple").css({"background-color":i.css("background-color"),"border-color":i.css("border-left-color"),"border-width":i.css("border-left-width"),"border-style":i.css("border-left-style"),"border-radius":i.css("border-top-left-radius")}).insertAfter(i);e('<li class="input-container">').addClass("flexdatalist-multiple-value").append(l).appendTo(o)}else l.insertAfter(i);i.addClass("flexdatalist").attr("type","hidden"),i._init=function(){l.on("input keydown",function(e){var t=i._keyword();188===a._keyNum(e)&&!n.selectionRequired&&n.multiple&&(e.preventDefault(),i._value(t),i._removeResults())}).on("input keyup",function(e){if(i._changed()&&13!==a._keyNum(e)){var t=i._keyword();t.length>=n.minLength?i._search(function(e){i._showResults(e)}):i._removeResults(),n.multiple||(n.selectionRequired?0!==t.length&&i._selected()||i._value(""):i._value(t))}s=i._keyword()}).focus(function(){0===n.minLength&&(""===i._keyword()?i._data(function(e){i._showResults(e)}):l.trigger("keyup"))}).blur(function(){n.selectionRequired&&!i._selected()&&i._value("")}).attr("autocomplete","off"),i.addClass("flexdatalist-set"),window.onresize=function(){i._position()}},i._changed=function(){return s!==i._keyword()},i._chained=function(){if(n.relatives&&n.chainedRelatives){var t=function(t){n.relatives.each(function(){var r=a._isEmpty(e(this).val()),s=a._isEmpty(i.val());l.prop("disabled",r),t||!r&&s||(i._value(""),l.val(""),n.multiple&&o.find("li .remove").click())})};n.relatives.on("change",function(){t(),r={}}),t(!0)}},i._initValue=function(){var e=i.attr("value");a._isEmpty(e)||i._parseValue(e,function(e){a._isEmpty(e)||(i.val(""),i._values(e)),s=i._keyword()})},i._parseValue=function(e,t){if(i._toJSON())try{t(JSON.parse(e))}catch(a){}else if(i._toCSV()||"string"==typeof n.valueProperty){var r=e.split(",");if("string"==typeof n.valueProperty){var s=n.searchIn;n.searchIn=n.valueProperty.split(","),n.searchEqual=!0,i._search(function(e,i){i.length>0&&t(i),n.searchIn=s,n.searchEqual=!1},r)}else t(r)}else t(e)},i._data=function(t){if(a._isObject(n.data)&&!a._isEmpty(n.data))return void t(n.data);if("string"==typeof n.data)n.url=n.data;else if(a._isEmpty(n.url)&&a._isEmpty(n.data))return;var r=i._keyword(),s=r.substring(0,n.minLength),l=i._cache(s);return l?void t(l):void(i.hasClass("flexdatalist-loading")||(i.addClass("flexdatalist-loading"),e.ajax({url:n.url,data:e.extend(i._relativesData(),n.params,{keyword:r,contain:n.searchContain,selected:i.val()}),type:"post",dataType:"json",success:function(e){i.removeClass("flexdatalist-loading");var r=e.results?e.results:e;"string"==typeof r&&0===r.indexOf("[{")&&(r=JSON.parse(r)),a._isObject(r)&&(t(r),"string"==typeof n.data?n.data=r:a._isEmpty(n.url)||a._isEmpty(r)||i._cache(s,r))}})))},i._relativesData=function(){var t={};return n.relatives&&(t.relatives={},n.relatives.each(function(){var i=e(this);t.relatives[i.attr("name")]=i.val()})),t},i._datalist=function(){var t=i.attr("list");return a._isEmpty(t)||(n.data=[],e("#"+t).find("option").each(function(){var t=e(this).val();n.data.push({label:t,value:t})})),i},i._cache=function(e,t){if(n.cache){if(e=i._normalizeString(e),!a._isDefined(t))return a._isDefined(r,e)&&(t=r[e]),t;r[e]=t}return null},i._search=function(e,t){i._data(function(r){var s=[],l=[];a._isDefined(t)||(t=i._keyword()),"string"==typeof t&&(t=[t]);for(var o=n.groupBy,u=0;u<t.length;u++)for(var c=t[u],d=0;d<r.length;d++){var f=i._matches(r[d],c);if(f)if(l.push(f),o){if(a._isDefined(f,o)){var p=f[o];a._isDefined(s,p)||(s[p]=[]),s[p].push(f)}}else s.push(f)}e(s,l)})},i._matches=function(e,t){for(var r=!1,s=0;s<n.searchIn.length;s++){var l=n.searchIn[s];if(a._isDefined(e,l)){var o=e[l];i._find(t,o,e)&&(e[l+"_highlight"]=i._highlight(t,o),r=!0)}}return r?e:null},i._highlight=function(e,t){return t.replace(new RegExp(e,n.searchContain?"ig":"i"),'<span class="highlight">$&</span>')},i._find=function(e,t){return t=i._normalizeString(t),e=i._normalizeString(e),n.searchEqual?t==e:n.searchContain?t.indexOf(e)>=0:0===t.indexOf(e)},i._showResults=function(t){i._removeResults();var a=i._getResultsContainer();i._selected()&&i._selected(!1)._value(""),n.groupBy?Object.keys(t).forEach(function(r){var s=t[r],l=n.groupBy,o=i._getHighlight(s[0],l,r);e("<li>").addClass("group").append(e("<span>").addClass("group-name").html(o)).append(e("<span>").addClass("group-item-count").text(" "+s.length)).appendTo(a);i._items(s,a)}):i._items(t,a);var r=a.find("li:not(.group)");r.on("click",function(){var t=e(this).data("item");t&&(i._selected(!0)._removeResults()._value(t),i.trigger("select:flexdatalist",[t,n]))}).hover(function(){r.removeClass("active"),e(this).addClass("active")},function(){e(this).removeClass("active")}),n.focusFirstResult&&r.filter(":first").addClass("active"),i._position()},i._getResultsContainer=function(){var t=i;n.multiple&&(t=o);var a=e("ul.flexdatalist-results");return 0===a.length&&(a=e("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":t.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":t.css("border-bottom-left-radius"),"border-bottom-right-radius":t.css("border-bottom-right-radius")}).data("target",l)),a},i._items=function(e,t){for(var a=n.maxShownResults,r=0;r<e.length&&!(a>0&&a===r);r++)i._item(e[r]).appendTo(t)},i._item=function(t){for(var r=e("<li>").data("item",t).addClass("item"),s=0;s<n.visibleProperties.length;s++){var l=n.visibleProperties[s];if((!n.groupBy||n.groupBy!==l)&&a._isDefined(t,l)){var o={};if("thumb"===l)o=e("<img>").addClass("item item-"+l).attr("src",t[l]);else{var u=i._getHighlight(t,l);o=e("<span>").addClass("item item-"+l).html(u+" ")}o.appendTo(r)}}return r},i._removeResults=function(){return e("ul.flexdatalist-results").remove(),i},i._selected=function(e){var t="flexdatalist-selected";return a._isDefined(e)?(e?i.addClass(t):i.removeClass(t),i):i.hasClass(t)},i._values=function(t){return e.isArray(t)&&!a._isEmpty(t)?void e.each(t,function(e,t){i._value(t)}):void i._value(t)},i._value=function(t){var a=i._getText(t),r=i._getValue(t);if(n.multiple){if(""===t)return i;l.val("");var u=e("<li>").addClass("value").append('<span class="text">'+a+"</span>").append('<span class="fdl-remove">&times;</span>').insertBefore(o.find("li.input-container"));u.find("span.fdl-remove").click(function(){var t=e(this).parent();if(i._toJSON()||i._toCSV()){var a=i._inputValue();a.splice(t.index(),1),i._inputValue(a)}t.remove()})}else a&&a!==l.val()&&l.val(a);return i._inputValue(r,a),s=i._keyword(),i},i._inputValue=function(e,t){var r=i._toJSON(),s=i._toCSV();return a._isDefined(e)?(a._isObject(e)&&(r&&!a._isEmpty(e)?e=JSON.stringify(e):s&&(e=e.join(","))),i.val(e),i.trigger("change:flexdatalist",[e,t,n]).trigger("change"),e):(e=i.val(),e?r?e=JSON.parse(e):s&&(e=e.split(",")):(r||s)&&(e=[]),e)},i._getText=function(e){var t=e;return a._isObject(e)&&(t=e[n.searchIn[0]],t=a._isDefined(e,n.textProperty)?e[n.textProperty]:i._replacePlaceholders(e,n.textProperty,t)),t},i._getValue=function(t){var r=t;if(a._isObject(t))if(r=t[n.searchIn[0]],"*"===n.valueProperty)r=t;else if(a._isDefined(t,n.valueProperty))r=t[n.valueProperty];else if(i._toJSON()){var r={},s=n.valueProperty,l=n.textProperty;if(l){var o=l;"string"==typeof l&&(o=i._parsePlaceholders(l)),a._isObject(o)&&e.each(o,function(e,t){s.push(t)})}else a._isDefined(t,l)&&s.push(l);e.each(s,function(e,i){a._isDefined(t,i)&&(r[i]=t[i])})}if(n.multiple&&(i._toJSON()||i._toCSV())){var u=i._inputValue();!a._isEmpty(r)&&a._isObject(u)&&(u.push(r),r=u)}return r},i._replacePlaceholders=function(t,r,s){if(a._isObject(t)&&"string"==typeof r){var n=i._parsePlaceholders(r);if(!a._isEmpty(t)&&n)return e.each(n,function(e,i){a._isDefined(t,i)&&(r=r.replace(e,t[i]))}),r}return s},i._parsePlaceholders=function(e){var t=e.match(/\{.+?\}/g);if(t){var i={};return t.map(function(e){i[e]=e.slice(1,-1)}),i}return!1},i._normalizeString=function(e){return"string"==typeof e?("function"==typeof n.normalizeString&&(e=n.normalizeString(e)),e.toUpperCase()):e},i._keyword=function(){return l.val().replace(/^\s+/,"")},i._toJSON=function(){return a._isObject(n.valueProperty)||"*"===n.valueProperty},i._toCSV=function(){return!i._toJSON()&&n.multiple},i._getHighlight=function(e,t,i){return a._isDefined(e,t+"_highlight")?e[t+"_highlight"]:a._isDefined(e,t)?e[t]:i},i._position=function(){var t=l;n.multiple&&(t=o),e("ul.flexdatalist-results").css({width:t.outerWidth()+"px",top:t.offset().top+t.outerHeight()+"px",left:t.offset().left+"px","z-index":t.css("z-index")+1})},i._datalist(),i._init(),i._initValue(),i._chained(),s=i._keyword()}})},e("input.flexdatalist").flexdatalist()}(jQuery);
\ No newline at end of file
+!function(e){"use strict";e.fn.flexdatalist=function(t,i){var a=e(document),s=e(this),n=this;if(this._destroy=function(){return s.removeClass("flexdatalist-set").data("flexdatalist",null).off().val("").attr("type","text").next(".flexdatalist-alias, ul.flexdatalist-multiple").remove(),!1},this._reset=function(){this._destroy()},"string"==typeof t)if("function"==typeof this["_"+t]){if(!this["_"+t]())return}else if(i){var r=s.data("flexdatalist");return r[t]=i,void s.data("flexdatalist",r)}return this._keyNum=function(e){return e.which||e.keyCode},a.data("flexdatalist")||e(document).mouseup(function(t){var i=e(".flexdatalist-results"),a=i.data("target");a&&a.is(":focus")||i.is(t.target)||0!==i.has(t.target).length||i.remove()}).keydown(function(t){var i=e(".flexdatalist-results"),a=i.find("li"),s=a.filter(".active"),r=s.index(),l=a.length,o=n._keyNum(t);if(0!==l)if(13===o)t.preventDefault(),s.click();else if(40===o||38===o){t.preventDefault(),40===o?s=l>r&&s.nextAll(".item").first().length>0?s.removeClass("active").nextAll(".item").first().addClass("active"):a.removeClass("active").filter(".item:first").addClass("active"):38===o&&(s=r>0&&s.prevAll(".item").first().length>0?s.removeClass("active").prevAll(".item").first().addClass("active"):a.removeClass("active").filter(".item:last").addClass("active"));var u=(0===s.prev().length?s:s.prev()).position().top;i.animate({scrollTop:u+i.scrollTop()},100)}}).data("flexdatalist",!0),this._isEmpty=function(t){return n._isDefined(t)?null===t?!0:t===!0?!1:0===this._length(t)?!0:""===e.trim(t):!0},this._isObject=function(e){return e&&"object"==typeof e},this._length=function(e){return this._isObject(e)?Object.keys(e).length:"number"==typeof e.length?e.length:0},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this.each(function(){var i=e(this),a={},s="";i.attr("name");if(!i.hasClass("flexdatalist-set")){i._options=function(t,s){var r=i.data("flexdatalist");if(!n._isDefined(t))return i.data("flexdatalist");if(n._isDefined(s))r[t]=s;else{if(!n._isObject(t))return n._isDefined(r,t)?r[t]:null;r=t}return r.searchIn="string"==typeof r.searchIn?r.searchIn.split(","):r.searchIn,r.relatives=r.relatives&&e(r.relatives).length>0?e(r.relatives):null,i.data("flexdatalist",r),a={},i},i._textProperty=function(){var e=i._options();return null===e.textProperty?e.searchIn[0]:e.textProperty},i._options(e.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:!1,cache:!0,minLength:2,groupBy:!1,selectionRequired:!1,focusFirstResult:!1,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:!1,searchEqual:!1,normalizeString:null,multiple:i.attr("multiple"),maxShownResults:100},t,i.data()));var r=i.clone(!1).attr({list:null,name:null}).addClass("flexdatalist-alias").removeClass("flexdatalist");if(i._options("multiple")){var l=e("<ul>").addClass("flexdatalist-multiple").css({"background-color":i.css("background-color"),"border-color":i.css("border-left-color"),"border-width":i.css("border-left-width"),"border-style":i.css("border-left-style"),"border-radius":i.css("border-top-left-radius")}).insertAfter(i);e('<li class="input-container">').addClass("flexdatalist-multiple-value").append(r).appendTo(l)}else r.insertAfter(i);i.addClass("flexdatalist").attr("type","hidden"),i._init=function(){var e=i._options();r.on("input keydown",function(t){var a=i._keyword();188===n._keyNum(t)&&!e.selectionRequired&&e.multiple&&(t.preventDefault(),i._value(a),i._removeResults())}).on("input keyup",function(t){if(i._changed()&&13!==n._keyNum(t)){var a=i._keyword();a.length>=e.minLength?i._search(function(e){i._showResults(e)}):i._removeResults(),e.multiple||(e.selectionRequired?0!==a.length&&i._selected()||i._value(""):i._value(a))}s=i._keyword()}).focus(function(){0===e.minLength&&(""===i._keyword()?i._data(function(e){i._showResults(e)}):r.trigger("keyup"))}).blur(function(){e.selectionRequired&&!i._selected()&&i._value("")}).attr("autocomplete","off"),i.addClass("flexdatalist-set"),window.onresize=function(){i._position()}},i._changed=function(){return s!==i._keyword()},i._chained=function(){var t=i._options();if(t.relatives&&t.chainedRelatives){var s=function(a){t.relatives.each(function(){var s=n._isEmpty(e(this).val()),o=n._isEmpty(i.val());r.prop("disabled",s),a||!s&&o||(i._value(""),r.val(""),t.multiple&&l.find("li .remove").click())})};t.relatives.on("change",function(){s(),a={}}),s(!0)}},i._initValue=function(){var e=i.attr("value");n._isEmpty(e)||i._parseValue(e,function(e){n._isEmpty(e)||(i.val(""),i._values(e)),s=i._keyword()})},i._parseValue=function(e,t){var a=i._options();if(i._toJSON())try{t(JSON.parse(e))}catch(s){}else if(i._toCSV()||"string"==typeof a.valueProperty){var n=e.split(",");if("string"==typeof a.valueProperty){var r=a.searchIn;a.searchIn=a.valueProperty.split(","),a.searchEqual=!0,i._search(function(e,i){i.length>0&&t(i),a.searchIn=r,a.searchEqual=!1},n)}else t(n)}else t(e)},i._data=function(t){var a=i._options(),s=a.url;if(n._isObject(a.data)&&!n._isEmpty(a.data))return void t(a.data);if("string"==typeof a.data)s=a.data;else if(n._isEmpty(a.url)&&n._isEmpty(a.data))return;var r=i._keyword(),l=r.substring(0,a.minLength),o=i._cache(l);return o?void t(o):void(i.hasClass("flexdatalist-loading")||(i.addClass("flexdatalist-loading"),e.ajax({url:s,data:e.extend(i._relativesData(),a.params,{keyword:r,contain:a.searchContain,selected:i.val()}),type:"post",dataType:"json",success:function(e){i.removeClass("flexdatalist-loading");var s=e.results?e.results:e;"string"==typeof s&&0===s.indexOf("[{")&&(s=JSON.parse(s)),n._isObject(s)&&(t(s),"string"==typeof a.data?a.data=s:n._isEmpty(a.url)||n._isEmpty(s)||i._cache(l,s))}})))},i._relativesData=function(){var t=i._options("relatives"),a={};return t&&(a.relatives={},t.each(function(){var t=e(this);a.relatives[t.attr("name")]=t.val()})),a},i._datalist=function(){var t=i._options(),a=i.attr("list");return n._isEmpty(a)||(t.data=[],e("#"+a).find("option").each(function(){var i=e(this).val();t.data.push({label:i,value:i})})),i},i._cache=function(e,t){if(i._options("cache")){if(e=i._normalizeString(e),!n._isDefined(t))return n._isDefined(a,e)&&(t=a[e]),t;a[e]=t}return null},i._search=function(e,t){i._data(function(a){var s=[],r=[];n._isDefined(t)||(t=i._keyword()),"string"==typeof t&&(t=[t]);for(var l=i._options("groupBy"),o=0;o<t.length;o++)for(var u=t[o],f=0;f<a.length;f++){var d=i._matches(a[f],u);if(d)if(r.push(d),l){if(n._isDefined(d,l)){var c=d[l];n._isDefined(s,c)||(s[c]=[]),s[c].push(d)}}else s.push(d)}e(s,r)})},i._matches=function(e,t){for(var a=!1,s=i._options("searchIn"),r=0;r<s.length;r++){var l=s[r];if(n._isDefined(e,l)){var o=e[l];i._find(t,o,e)&&(e[l+"_highlight"]=i._highlight(t,o),a=!0)}}return a?e:null},i._highlight=function(e,t){return t.replace(new RegExp(e,i._options("searchContain")?"ig":"i"),'<span class="highlight">$&</span>')},i._find=function(e,t){var a=i._options();return t=i._normalizeString(t),e=i._normalizeString(e),a.searchEqual?t==e:a.searchContain?t.indexOf(e)>=0:0===t.indexOf(e)},i._showResults=function(t){i._removeResults();var a=i._getResultsContainer(),s=i._options();i._selected()&&i._selected(!1)._value(""),s.groupBy?Object.keys(t).forEach(function(n){var r=t[n],l=s.groupBy,o=i._getHighlight(r[0],l,n);e("<li>").addClass("group").append(e("<span>").addClass("group-name").html(o)).append(e("<span>").addClass("group-item-count").text(" "+r.length)).appendTo(a);i._items(r,a)}):i._items(t,a);var n=a.find("li:not(.group)");n.on("click",function(){var t=e(this).data("item");t&&(i._selected(!0)._removeResults()._value(t),i.trigger("select:flexdatalist",[t,s]))}).hover(function(){n.removeClass("active"),e(this).addClass("active")},function(){e(this).removeClass("active")}),s.focusFirstResult&&n.filter(":first").addClass("active"),i._position()},i._getResultsContainer=function(){var t=i;i._options("multiple")&&(t=l);var a=e("ul.flexdatalist-results");return 0===a.length&&(a=e("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":t.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":t.css("border-bottom-left-radius"),"border-bottom-right-radius":t.css("border-bottom-right-radius")}).data("target",r)),a},i._items=function(e,t){for(var a=i._options("maxShownResults"),s=0;s<e.length&&!(a>0&&a===s);s++)i._item(e[s]).appendTo(t)},i._item=function(t){for(var a=e("<li>").data("item",t).addClass("item"),s=i._options(),r=0===s.visibleProperties.length?s.searchIn:s.visibleProperties,l=0;l<r.length;l++){var o=r[l];if((!s.groupBy||s.groupBy!==o)&&n._isDefined(t,o)){var u={};if("thumb"===o)u=e("<img>").addClass("item item-"+o).attr("src",t[o]);else{var f=i._getHighlight(t,o);u=e("<span>").addClass("item item-"+o).html(f+" ")}u.appendTo(a)}}return a},i._removeResults=function(){return e("ul.flexdatalist-results").remove(),i},i._selected=function(e){var t="flexdatalist-selected";return n._isDefined(e)?(e?i.addClass(t):i.removeClass(t),i):i.hasClass(t)},i._values=function(t){return e.isArray(t)&&!n._isEmpty(t)?void e.each(t,function(e,t){i._value(t)}):void i._value(t)},i._value=function(t){var a=i._getText(t),n=i._getValue(t);if(i._options("multiple")){if(""===t)return i;r.val("");var o=e("<li>").addClass("value").append('<span class="text">'+a+"</span>").append('<span class="fdl-remove">&times;</span>').insertBefore(l.find("li.input-container"));o.find("span.fdl-remove").click(function(){var t=e(this).parent();if(i._toJSON()||i._toCSV()){var a=i._inputValue();a.splice(t.index(),1),i._inputValue(a)}t.remove()})}else a&&a!==r.val()&&r.val(a);return i._inputValue(n,a),s=i._keyword(),i},i._inputValue=function(e,t){var a=i._toJSON(),s=i._toCSV();return n._isDefined(e)?(n._isObject(e)&&(a&&!n._isEmpty(e)?e=JSON.stringify(e):s&&(e=e.join(","))),i.val(e),i.trigger("change:flexdatalist",[e,t,i._options()]).trigger("change"),e):(e=i.val(),e?a?e=JSON.parse(e):s&&(e=e.split(",")):(a||s)&&(e=[]),e)},i._getText=function(e){var t=e,a=i._options("searchIn"),s=i._textProperty();return n._isObject(e)&&(t=e[a[0]],t=n._isDefined(e,s)?e[s]:i._replacePlaceholders(e,s,t)),t},i._getValue=function(t){var a=t,s=i._options();if(n._isObject(t))if(a=t[s.searchIn[0]],"*"===s.valueProperty)a=t;else if(n._isDefined(t,s.valueProperty))a=t[s.valueProperty];else if(i._toJSON()){var a={},r=s.valueProperty,l=i._textProperty();if(l){var o=l;"string"==typeof l&&(o=i._parsePlaceholders(l)),n._isObject(o)&&e.each(o,function(e,t){r.push(t)})}else n._isDefined(t,l)&&r.push(l);e.each(r,function(e,i){n._isDefined(t,i)&&(a[i]=t[i])})}if(s.multiple&&(i._toJSON()||i._toCSV())){var u=i._inputValue();!n._isEmpty(a)&&n._isObject(u)&&(u.push(a),a=u)}return a},i._replacePlaceholders=function(t,a,s){if(n._isObject(t)&&"string"==typeof a){var r=i._parsePlaceholders(a);if(!n._isEmpty(t)&&r)return e.each(r,function(e,i){n._isDefined(t,i)&&(a=a.replace(e,t[i]))}),a}return s},i._parsePlaceholders=function(e){var t=e.match(/\{.+?\}/g);if(t){var i={};return t.map(function(e){i[e]=e.slice(1,-1)}),i}return!1},i._normalizeString=function(e){if("string"==typeof e){var t=i._options("normalizeString");return"function"==typeof t&&(e=t(e)),e.toUpperCase()}return e},i._keyword=function(){return r.val().replace(/^\s+/,"")},i._toJSON=function(){var e=i._options("valueProperty");return n._isObject(e)||"*"===e},i._toCSV=function(){return!i._toJSON()&&i._options("multiple")},i._getHighlight=function(e,t,i){return n._isDefined(e,t+"_highlight")?e[t+"_highlight"]:n._isDefined(e,t)?e[t]:i},i._position=function(){var t=r;i._options("multiple")&&(t=l),e("ul.flexdatalist-results").css({width:t.outerWidth()+"px",top:t.offset().top+t.outerHeight()+"px",left:t.offset().left+"px","z-index":t.css("z-index")+1})},i._datalist(),i._init(),i._initValue(),i._chained(),s=i._keyword()}})},e("input.flexdatalist").flexdatalist()}(jQuery);
\ No newline at end of file

allowing to add/change option(s) after input instance initialization