Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix compatibility with jQuery 1.9.x #52

Merged
merged 1 commit into from

2 participants

@michaelperrin

I changed all the .attr('value') and .attr('value', myVal) respectively by .val() and .attr(myVal).

Everything works fine now.

@michaelperrin

@meltingice Any news on this? It's totally harmless, I promise! Even for older versions of jQuery.

@meltingice meltingice merged commit cd97514 into from
@meltingice
Owner

Sorry about the delay, merged it in.

@michaelperrin

Thanks! That was fast actually!

@michaelperrin michaelperrin deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2013
  1. @michaelperrin
This page is out of date. Refresh to see the latest.
View
8 lib/ajax-chosen.js
@@ -26,8 +26,8 @@
return this.each(function() {
return $(this).next('.chzn-container').find(".search-field > input, .chzn-search > input").bind('keyup', function() {
var field, msg, success, untrimmed_val, val;
- untrimmed_val = $(this).attr('value');
- val = $.trim($(this).attr('value'));
+ untrimmed_val = $(this).val();
+ val = $.trim($(this).val());
msg = val.length < options.minTermLength ? options.keepTypingMsg : options.lookingForMsg + (" '" + val + "'");
select.next('.chzn-container').find('.no-results').text(msg);
if (val === $(this).data('prevVal')) {
@@ -106,12 +106,12 @@
select.trigger("liszt:updated");
} else {
select.data().chosen.no_results_clear();
- select.data().chosen.no_results(field.attr('value'));
+ select.data().chosen.no_results(field.val());
}
if (success != null) {
success(data);
}
- return field.attr('value', untrimmed_val);
+ return field.val(untrimmed_val);
};
return this.timer = setTimeout(function() {
if (chosenXhr) {
View
6 lib/ajax-chosen.min.js
@@ -2,7 +2,7 @@
(function($){return $.fn.ajaxChosen=function(settings,callback,chosenOptions){var chosenXhr,defaultOptions,options,select;if(settings==null){settings={};}
if(callback==null){callback={};}
if(chosenOptions==null){chosenOptions=function(){};}
-defaultOptions={minTermLength:3,afterTypeDelay:500,jsonTermKey:"term",keepTypingMsg:"Keep typing...",lookingForMsg:"Looking for"};select=this;chosenXhr=null;options=$.extend({},defaultOptions,$(select).data(),settings);this.chosen(chosenOptions?chosenOptions:{});return this.each(function(){return $(this).next('.chzn-container').find(".search-field > input, .chzn-search > input").bind('keyup',function(){var field,msg,success,untrimmed_val,val;untrimmed_val=$(this).attr('value');val=$.trim($(this).attr('value'));msg=val.length<options.minTermLength?options.keepTypingMsg:options.lookingForMsg+(" '"+val+"'");select.next('.chzn-container').find('.no-results').text(msg);if(val===$(this).data('prevVal')){return false;}
+defaultOptions={minTermLength:3,afterTypeDelay:500,jsonTermKey:"term",keepTypingMsg:"Keep typing...",lookingForMsg:"Looking for"};select=this;chosenXhr=null;options=$.extend({},defaultOptions,$(select).data(),settings);this.chosen(chosenOptions?chosenOptions:{});return this.each(function(){return $(this).next('.chzn-container').find(".search-field > input, .chzn-search > input").bind('keyup',function(){var field,msg,success,untrimmed_val,val;untrimmed_val=$(this).val();val=$.trim($(this).val());msg=val.length<options.minTermLength?options.keepTypingMsg:options.lookingForMsg+(" '"+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={};}
@@ -11,7 +11,7 @@ success=options.success;options.success=function(data){var items,nbItems,selecte
selected_values=[];select.find('option').each(function(){if(!$(this).is(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});select.find('optgroup:empty').each(function(){return $(this).remove();});items=callback(data);nbItems=0;$.each(items,function(i,element){var group,text,value;nbItems++;if(element.group){group=select.find("optgroup[label='"+element.text+"']");if(!group.size()){group=$("<optgroup />");}
group.attr('label',element.text).appendTo(select);return $.each(element.items,function(i,element){var text,value;if(typeof element==="string"){value=i;text=element;}else{value=element.value;text=element.text;}
if($.inArray(value+"-"+text,selected_values)===-1){return $("<option />").attr('value',value).html(text).appendTo(group);}});}else{if(typeof element==="string"){value=i;text=element;}else{value=element.value;text=element.text;}
-if($.inArray(value+"-"+text,selected_values)===-1){return $("<option />").attr('value',value).html(text).appendTo(select);}}});if(nbItems){select.trigger("liszt:updated");}else{select.data().chosen.no_results_clear();select.data().chosen.no_results(field.attr('value'));}
+if($.inArray(value+"-"+text,selected_values)===-1){return $("<option />").attr('value',value).html(text).appendTo(select);}}});if(nbItems){select.trigger("liszt:updated");}else{select.data().chosen.no_results_clear();select.data().chosen.no_results(field.val());}
if(success!=null){success(data);}
-return field.attr('value',untrimmed_val);};return this.timer=setTimeout(function(){if(chosenXhr){chosenXhr.abort();}
+return field.val(untrimmed_val);};return this.timer=setTimeout(function(){if(chosenXhr){chosenXhr.abort();}
return chosenXhr=$.ajax(options);},options.afterTypeDelay);});});};})(jQuery);
View
10 src/ajax-chosen.coffee
@@ -31,8 +31,8 @@ do ($ = jQuery) ->
# into the input form that chosen has created
# Retrieve the current value of the input form
- untrimmed_val = $(@).attr('value')
- val = $.trim $(@).attr('value')
+ untrimmed_val = $(@).val()
+ val = $.trim $(@).val()
# Depending on how much text the user has typed, let them know
# if they need to keep typing or if we are looking for their data
@@ -139,8 +139,8 @@ do ($ = jQuery) ->
else
# If there are no results, display the no_results text
select.data().chosen.no_results_clear()
- select.data().chosen.no_results field.attr('value')
-
+ select.data().chosen.no_results field.val()
+
# Finally, call the user supplied callback (if it exists)
success(data) if success?
@@ -148,7 +148,7 @@ do ($ = jQuery) ->
# call trigger above. Often, this can be very annoying (and can make some
# searches impossible), so we add the value the user was typing back into
# the input field.
- field.attr('value', untrimmed_val)
+ field.val(untrimmed_val)
# Because non-ajax Chosen isn't constantly re-building results, when it
# DOES rebuild results (during liszt:updated above, it clears the input
Something went wrong with that request. Please try again.