Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • They were not! Making that change fixed the issue! Sorry for taking your time with this. In the end the problem was caused by the theme and not Meta Box nor my code.
    I’m really really thankful!

    Sadly I think my client wouldn’t allow it. I’m working for someone else. I’ll ask him tomorrow anyway.

    Here I found some of the customizations that the theme has. Maybe this has to do with it since it’s not including rwmb.

    
    jQuery( function ( $ )
    {
    	'use strict';
    
    	$(document).ready(function(){
    
    		/*if ( $('#_tour_charge_child').length ) {
    			$('#_tour_charge_child').change(function(){
    				$('#_tour_price_child').closest('.rwmb-field').toggle(this.checked);
    			});
    			$('#_tour_charge_child').trigger('change');
    		}
    */
    		if ( $('input[name="_tour_repeated"]').length ) {
    			$('input[name="_tour_repeated"]').change(function(){ toggleDatePicker();});
    			toggleDatePicker();
    		}
    
    		function toggleDatePicker() {
    			var flag = true;
    			if ( $('input[name="_tour_repeated"]:checked').val() == 1 ) flag = false;
    
    			$('input[name="_tour_date"]').closest('.rwmb-field').toggle(flag);
    			$('input[name="_tour_start_date"]').closest('.rwmb-field').toggle(!flag);
    			$('input[name="_tour_end_date"]').closest('.rwmb-field').toggle(!flag);
    			$('select[name="_tour_available_days[]"]').closest('.rwmb-field').toggle(!flag);
    		}
    
    		if ( $('.ct_datepicker').length ) {
    			$('.ct_datepicker').datepicker({ dateFormat: "yy-mm-dd" });
    		}
            
    		if ( $('.has_multi_schedules').length ) {
    			$('.has_multi_schedules').change(function(){
    				var $wrapper = $(this).closest('.schedule-wrapper');
    				var $check_box = this;
    				$wrapper.find('.add-clone, .remove-clone, .schedule-header').toggle(this.checked); // hide add-clone, remove-clone, date fields
    				$wrapper.find('.rwmb-clone').each(function(index){
    					if ( index != 0 ) $(this).toggle($check_box.checked);
    				}); // hide the other schedules
    			});
    			$('.has_multi_schedules').trigger('change');
    		}
    	});
    } );
    

    Do every script using Meta Box need to inject the rwmb variable now? The original metabox is created by the theme that we are using and I found that there are some Metabox customisations involved.

    Here is the code that I use to add the clonable metaboxes to the corresponding Meta Box on the site:

    
    <?php
    
    if ( ! defined( 'WPINC' ) ) {
    	die;
    }
    
    add_filter( 'rwmb_meta_boxes', 'gcbti_add_tb_fields_to_tour', 20 );
    function gcbti_add_tb_fields_to_tour( $meta_boxes ) {
      foreach ( $meta_boxes as $k => &$meta_box ) {
        if ( isset( $meta_box['id'] ) && 'tour_default_details' == $meta_box['id'] ) {
          array_push(
            $meta_box['fields'],
            array(
              'name'         => 'Travel Builder Services',
              'id'           => "_tour_tb_services",
              'desc'         => 'Ingrese el Service ID de Travel Builder',
              'placeholder'  => 'Ingrese el ID',
              'type'         => 'tb-services-list',
              'service_type' => 'tour',
              'clone' => true,
              'clone_as_multiple' => true,
              'add_button' => 'Añadir otro ID'
            ),
            array(
              'name'         => 'Travel Builder Packages',
              'id'           => "_tour_tb_packages",
              'desc'         => 'Ingrese el Package ID de Travel Builder',
              'placeholder'  => 'Ingrese el ID',
              'type'         => 'tb-packages-list',
              'service_type' => 'tour',
              'clone' => true,
              'clone_as_multiple' => true,
              'add_button' => 'Añadir otro Paquete'
            )
          );
        }
      }
      return $meta_boxes;
    }
    

    I’ve just disabled all of my custom plugins that use Meta Box functionality and the error still persists.

    From Meta Box we are only using Meta Box and Meta Box Group. I have also developed some custom fields and pages.

    I’m also getting the same error with other files:
    clone.js:270:1
    date.js:68:1

    I have updated to the latest version (5.1.1) and cleared the cache many times.

    When I see the console, it seems like /meta-box/js/script.js, which defines rwmb, is being loaded AFTER many scripts (including the ones that give me the error) which might be the cause of the scripts not finding rmwb. Maybe the enqueue order has a problem. I’m not sure.

Viewing 7 replies - 1 through 7 (of 7 total)