Support » Plugin: Meta Box - WordPress Custom Fields Framework » rwmb is not defined

  • Resolved Ali Ayubi


    After updating to the latest version of this plugin i getting this error:

    rwmb is not defined at /wp-content/plugins/meta-box/js/select.js:22

    • This topic was modified 3 months, 2 weeks ago by Ali Ayubi.
    • This topic was modified 3 months, 2 weeks ago by Ali Ayubi.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Anh Tran


    Hi Ali,

    Can you please try re-installing the plugin and clearing the browser cache? The “rwmb” variable is added in the 5.0.0 version.



    I’m also getting the same error with other files:

    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.

    Plugin Author Anh Tran


    Hi @codesxt , can you please list the plugins you’re using? Yesterday, I found this bug in MB Frontend Submission and already fixed it.

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

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

    Plugin Author Anh Tran


    Hi @codesxt,

    Can you send me the code of your meta box to check? I’ve just tested with Meta Box & Meta Box group and couldn’t replicate the error.

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

    if ( ! defined( 'WPINC' ) ) {
    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'] ) {
              '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'
              '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;
    Plugin Author Anh Tran


    @codesxt, this is the code for adding 2 fields (with custom field types) to an existing meta box. And all of them don’t have group.

    Can you post the code of the original meta box?

    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.

    Plugin Author Anh Tran


    Yes, the “rwmb” variable essentially is enqueued before all scripts to make it available.

    I’m not sure what your case is. Can you send me a temporary admin account to check?

    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';
    		/*if ( $('#_tour_charge_child').length ) {
    		if ( $('input[name="_tour_repeated"]').length ) {
    			$('input[name="_tour_repeated"]').change(function(){ toggleDatePicker();});
    		function toggleDatePicker() {
    			var flag = true;
    			if ( $('input[name="_tour_repeated"]:checked').val() == 1 ) flag = false;
    		if ( $('.ct_datepicker').length ) {
    			$('.ct_datepicker').datepicker({ dateFormat: "yy-mm-dd" });
    		if ( $('.has_multi_schedules').length ) {
    				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
    					if ( index != 0 ) $(this).toggle($check_box.checked);
    				}); // hide the other schedules
    } );
    Plugin Author Anh Tran


    When this script (maybe others as well) is enqueued?

    Can you check if they’re enqueued using the rwmb_enqueue_scripts hook? Using it ensures the script is enqueued after rwmb is available.

    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!

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.