Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'model' of undefined in builder.js

Please help me regarding this error

Uncaught TypeError: Cannot read property 'model' of undefined" in Builder.js.

I'm using Extra theme from Elegant and I just updated my Wordpress to Version 4.5. When I tried to delete some sections in Divi Builder I got this error.

I don't know how to fix this. Uncaugth Error Elegant Theme

like image 368
Lodel Avatar asked Apr 15 '16 16:04

Lodel


People also ask

How do you fix TypeError Cannot read properties of undefined?

To solve the "Cannot read properties of undefined" error, use the optional chaining operator to check if the variable is not nullish before accessing it, e.g. person?. name . If the variable is undefined or null , the operator short-circuits instead of throwing an error.

What does Cannot read properties of undefined?

JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or function. This error occurs in Chrome Browser when you read a property or call a method on an undefined object .

Can not read the property of undefined Reading 0?

The "Cannot read Property '0' of undefined" error occurs when accessing an undefined value at index 0 . To solve the error, initialize the variable to the correct data type, e.g. array or string, before accessing the index.

What does Cannot read properties of null mean?

The "Cannot read property 'click' of null" error occurs when trying to call the click method on a null value. To solve the error, run the JS script after the DOM elements are available and make sure you only call the method on valid DOM elements.


1 Answers

I came across this error on the Divi Theme. This is how I got it fixed... It will probably work for you as well.

Divi/includes/builder/script/builder.js

Replace these lines (2 total)

if ( view['model']['attributes']['parent'] === parent_id )

With these lines

if ( view !== undefined && view['model']['attributes']['parent'] === parent_id )

And replace these 2 functions

getNumberOf : function( element_name, module_cid ) {
    var views = this.get( 'views' ),
        num = 0;

    _.each( views, function( view ) {
        var type = view['model']['attributes']['type'];

        if ( view['model']['attributes']['parent'] === module_cid && ( type === element_name || type === ( element_name + '_inner' ) ) )
            num++;
    } );

    return num;
},

getNumberOfModules : function( module_name ) {
    var views = this.get( 'views' ),
        num = 0;

    _.each( views, function( view ) {
        if ( view['model']['attributes']['type'] === module_name )
            num++;
    } );

    return num;
},

With these

getNumberOf : function( element_name, module_cid ) {
    var views = this.get( 'views' ),
        num = 0;

    _.each( views, function( view ) {
        if(view !== undefined){
            var type = view['model']['attributes']['type'];

            if ( view['model']['attributes']['parent'] === module_cid && ( type === element_name || type === ( element_name + '_inner' ) ) )
                num++;
        }
    } );

    return num;
},

getNumberOfModules : function( module_name ) {
    var views = this.get( 'views' ),
        num = 0;

    _.each( views, function( view ) {
        if(view !== undefined){
            if ( view['model']['attributes']['type'] === module_name )
                num++;
        }
    } );

return num;
},
like image 175
Roy Toledo Avatar answered Sep 28 '22 11:09

Roy Toledo