Skip to content

Instantly share code, notes, and snippets.

@artikus11
Created October 4, 2021 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artikus11/ee2bbb7ecac1bd7e86d433d0ca98f703 to your computer and use it in GitHub Desktop.
Save artikus11/ee2bbb7ecac1bd7e86d433d0ca98f703 to your computer and use it in GitHub Desktop.
$( '.feedback a' ).magnificPopup( {
type: 'ajax',
callbacks: {
elementParse: function( item ) {
postData = {
action: 'feedback_ajax_action',
form_id: $( item.el[0] ).attr( 'data-form-id' )
};
var mp = $.magnificPopup.instance;
mp.st.ajax.settings.data = postData;
},
ajaxContentAdded: function() {
$( 'div.wpcf7 > form' ).each( function() {
let $form = $( this );
wpcf7.init( this );
if ( wpcf7.cached ) {
wpcf7.refill( $form );
}
}
);
let mask_fields = $( '.wpcf7-mask' );
if ( mask_fields.length > 0 ) {
mask_fields.each( function() {
let $this = $( this ),
data_mask = $this.data( 'mask' );
//Если ошибка определения, то выводим в консоль сообщение и продолжаем
try {
$this.mask( data_mask );
if ( data_mask.indexOf( '*' ) === -1 && data_mask.indexOf( 'a' ) === -1 ) {
$this.attr( {
'inputmode': 'numeric'
} );
}
} catch ( e ) {
console.log( 'Error ' + e.name + ':' + e.message + '\n' + e.stack );
}
}
);
}
}
},
ajax: {
settings: {
type: 'POST',
url: vv_feedback.url,
nonce: vv_feedback.nonce,
}
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment