1 line
1.5 KiB
JavaScript
1 line
1.5 KiB
JavaScript
((function(){(function(a){var b;return a.fn.ajaxChosen=function(c,d){var e;e=this;this.chosen();this.next(".chzn-container").find(".search-field > input").bind("keyup",function(){var f,g;g=a.trim(a(this).attr("value"));if(g.length<3||g===a(this).data("prevVal"))return!1;this.timer&&clearTimeout(this.timer);a(this).data("prevVal",g);f=a(this);c.data.term=g;if(typeof success=="undefined"||success===null)success=c.success;c.success=function(b){var c;if(b==null)return;e.find("option").each(function(){if(!a(this).is(":selected"))return a(this).remove()});c=d(b);a.each(c,function(b,c){return a("<option />").attr("value",b).html(c).appendTo(e)});e.trigger("liszt:updated");f.attr("value",g);if(typeof success!="undefined"&&success!==null)return success()};return this.timer=setTimeout(function(){b&&b.abort();b=a.ajax(c);return b},800)});return this.next(".chzn-container").find(".chzn-search > input").bind("keyup",function(){var f,g;g=a.trim(a(this).attr("value"));if(g.length<3||g===a(this).data("prevVal"))return!1;f=a(this);c.data={term:g};if(typeof success=="undefined"||success===null)success=c.success;c.success=function(b){var c;if(b==null)return;e.find("option").each(function(){return a(this).remove()});c=d(b);a.each(c,function(b,c){return a("<option />").attr("value",b).html(c).appendTo(e)});e.trigger("liszt:updated");f.attr("value",g);if(typeof success!="undefined"&&success!==null)return success()};return this.timer=setTimeout(function(){b&&b.abort();b=a.ajax(c);return b},800)})}})(jQuery)})).call(this); |