Bind price and decimal input events to body in woocommerce_admin js

The event was bound to the element directly, causing problems when the elements was added after dom ready (through ajax). Now the decimal format check will always take place.
This commit is contained in:
Mike Martel 2014-04-17 12:50:43 +02:00
parent 3d584bc09a
commit e0dc31620b
1 changed files with 40 additions and 43 deletions

View File

@ -4,14 +4,12 @@
jQuery(function(){
// Price input validation
jQuery(".wc_input_decimal[type=text], .wc_input_price[type=text]")
.bind( 'blur', function() {
jQuery('body').on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text]', function() {
jQuery('.wc_error_tip').fadeOut('100', function(){ jQuery(this).remove(); } );
return this;
});
jQuery(".wc_input_price[type=text]")
.bind( 'keyup change', function() {
jQuery('body').on('keyup change', '.wc_input_price[type=text]', function(){
var value = jQuery(this).val();
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.mon_decimal_point + "]+", "gi" );
var newvalue = value.replace( regex, '' );
@ -30,8 +28,7 @@ jQuery(function(){
return this;
});
jQuery(".wc_input_decimal[type=text]")
.bind( 'keyup change', function() {
jQuery('body').on('keyup change', '.wc_input_price[type=text]', function(){
var value = jQuery(this).val();
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.decimal_point + "]+", "gi" );
var newvalue = value.replace( regex, '' );