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:
parent
3d584bc09a
commit
e0dc31620b
|
@ -4,14 +4,12 @@
|
||||||
jQuery(function(){
|
jQuery(function(){
|
||||||
|
|
||||||
// Price input validation
|
// Price input validation
|
||||||
jQuery(".wc_input_decimal[type=text], .wc_input_price[type=text]")
|
jQuery('body').on( 'blur', '.wc_input_decimal[type=text], .wc_input_price[type=text]', function() {
|
||||||
.bind( 'blur', function() {
|
|
||||||
jQuery('.wc_error_tip').fadeOut('100', function(){ jQuery(this).remove(); } );
|
jQuery('.wc_error_tip').fadeOut('100', function(){ jQuery(this).remove(); } );
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery(".wc_input_price[type=text]")
|
jQuery('body').on('keyup change', '.wc_input_price[type=text]', function(){
|
||||||
.bind( 'keyup change', function() {
|
|
||||||
var value = jQuery(this).val();
|
var value = jQuery(this).val();
|
||||||
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.mon_decimal_point + "]+", "gi" );
|
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.mon_decimal_point + "]+", "gi" );
|
||||||
var newvalue = value.replace( regex, '' );
|
var newvalue = value.replace( regex, '' );
|
||||||
|
@ -30,8 +28,7 @@ jQuery(function(){
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery(".wc_input_decimal[type=text]")
|
jQuery('body').on('keyup change', '.wc_input_price[type=text]', function(){
|
||||||
.bind( 'keyup change', function() {
|
|
||||||
var value = jQuery(this).val();
|
var value = jQuery(this).val();
|
||||||
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.decimal_point + "]+", "gi" );
|
var regex = new RegExp( "[^0-9\%.\\" + woocommerce_admin.decimal_point + "]+", "gi" );
|
||||||
var newvalue = value.replace( regex, '' );
|
var newvalue = value.replace( regex, '' );
|
||||||
|
|
Loading…
Reference in New Issue