jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When editing a post, every single input is forced a change event

csrui opened this issue · comments

This block of code is being executed on elements that have no business touching.

    var uniqueFormElms = [];
    $(':input', changeContext).each( function(i,e) {
      var elmName = $(e).attr('name');
      if( typeof elmName !== 'undefined' && elmName !== '' && $.inArray( elmName, uniqueFormElms ) === -1 ) {
        uniqueFormElms.push( elmName );
      }
    });
    for( var i = 0; i < uniqueFormElms.length; i++ ) {
      var formElms = $('[name="' + uniqueFormElms[i] + '"]');
      if(formElms.length === 1 || ! formElms.is(':checked')) {
        formElms.trigger('change');
      } else {
        formElms.filter(':checked').trigger('change');
      }
    }

For example the language dropdown is being triggered which produced a modal box every time we try to edit a post or page.

formElms.trigger('change');

editar_pagina_ _fundacao_calouste_gulbenkian_ _wordpress

/cc @Goncalom

We have reports of this in the WPML support forum too:
https://wpml.org/es/forums/topic/al-abrir-los-productos-me-aparece-un-mensaje-para-cambiar-el-idioma-del-mismo/

What happens is that WPML displays a popup notice when the language of a post is changed. In this case the language hasn't really been changed, just the 'change' event has been triggered by the JS code mentioned in the previous comment.

Let me know if you need a WPML subscription to test this.

This plugin allows for conditions based on the "normal" WP edit post fields as well, so the triggering of the change event is correct AFAICS. Could you explain in more detail what the actual problem is that's being caused by it ? Maybe with some screenshots ?

At this point, this is no longer an issue as this occurred with a very dated version of tribe events