Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Recompiled to JS

  • Loading branch information...
commit 0546e3d220bd3e5a5c6daab38e86453e500d7c58 1 parent 7dc2d08
@meltingice authored
View
2  docs/ajax-chosen.html
@@ -45,7 +45,7 @@
value => text pairs to inject as <option> elements.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">items = </span><span class="nx">callback</span> <span class="nx">data</span>
</pre></div> </td> </tr> <tr id="section-21"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-21">&#182;</a> </div> <p>Iterate through the given data and inject the <option> elements into
the DOM if it doesn't exist in the selector already</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">$</span><span class="p">.</span><span class="nx">each</span> <span class="nx">items</span><span class="p">,</span> <span class="nf">(value, text) -&gt;</span>
- <span class="k">if</span> <span class="nx">selected_values</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span> <span class="o">+</span> <span class="nx">text</span><span class="p">)</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span>
+ <span class="k">if</span> <span class="nx">$</span><span class="p">.</span><span class="nx">inArray</span><span class="p">(</span><span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span> <span class="o">+</span> <span class="nx">text</span><span class="p">,</span> <span class="nx">selected_values</span><span class="p">)</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span>
<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;&lt;option /&gt;&quot;</span><span class="p">)</span>
<span class="p">.</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span>
<span class="p">.</span><span class="nx">html</span><span class="p">(</span><span class="nx">text</span><span class="p">)</span>
View
2  lib/ajax-chosen.js
@@ -43,7 +43,7 @@
});
items = callback(data);
$.each(items, function(value, text) {
- if (selected_values.indexOf(value + "-" + text) === -1) {
+ if ($.inArray(value + "-" + text, selected_values) === -1) {
return $("<option />").attr('value', value).html(text).appendTo(select);
}
});
View
2  lib/ajax-chosen.min.js
@@ -1,3 +1,3 @@
(function($){if($==null)$=jQuery;return $.fn.ajaxChosen=function(settings,callback){var chosenXhr,defaultOptions,options,select;if(settings==null)settings={};if(callback==null)callback=function(){};defaultOptions={minTermLength:3,afterTypeDelay:500,jsonTermKey:"term"};select=this;chosenXhr=null;options=$.extend({},defaultOptions,settings);this.chosen();return this.each(function(){return $(this).next('.chzn-container').find(".search-field > input, .chzn-search > input").bind('keyup',function(){var field,msg,val;val=$.trim($(this).attr('value'));msg=val.length<options.minTermLength?"Keep typing...":"Looking for '"+val+"'";select.next('.chzn-container').find('.no-results').text(msg);if(val===$(this).data('prevVal'))return false;$(this).data('prevVal',val);if(this.timer)clearTimeout(this.timer);if(val.length<options.minTermLength)return false;field=$(this);if(!(options.data!=null))options.data={};options.data[options.jsonTermKey]=val;if(typeof success==="undefined"||success===null){success=options.success;}
-options.success=function(data){var items,selected_values;if(!(data!=null))return;selected_values=[];select.find('option').each(function(){if(!$(this).is(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});items=callback(data);$.each(items,function(value,text){if(selected_values.indexOf(value+"-"+text)===-1){return $("<option />").attr('value',value).html(text).appendTo(select);}});select.trigger("liszt:updated");if(typeof success!=="undefined"&&success!==null)success();field.attr('value',val);return field.css('width','auto');};return this.timer=setTimeout(function(){if(chosenXhr)chosenXhr.abort();return chosenXhr=$.ajax(options);},options.afterTypeDelay);});});};})($);
+options.success=function(data){var items,selected_values;if(!(data!=null))return;selected_values=[];select.find('option').each(function(){if(!$(this).is(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});items=callback(data);$.each(items,function(value,text){if($.inArray(value+"-"+text,selected_values)===-1){return $("<option />").attr('value',value).html(text).appendTo(select);}});select.trigger("liszt:updated");if(typeof success!=="undefined"&&success!==null)success();field.attr('value',val);return field.css('width','auto');};return this.timer=setTimeout(function(){if(chosenXhr)chosenXhr.abort();return chosenXhr=$.ajax(options);},options.afterTypeDelay);});});};})($);

0 comments on commit 0546e3d

Please sign in to comment.
Something went wrong with that request. Please try again.