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

3

8

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

Genarogendarme answered 15/4, 2016 at 16:55 Comment(2)
Welcome to StackOverflow! Before asking a question, please be sure to review the question in the preview box. Your current formatting is very difficult to read.Ninebark
Sorry for that. I'm new here. :)Genarogendarme
T
18

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;
},
Tenorite answered 9/5, 2016 at 8:26 Comment(4)
This fixed the issue for meMontenegro
Thank you so much! The only google results I could find were for the theme which is structured differently than the plugin, this works great!Laufer
Works for Divi 2.4.3 , WP 4.7.5. Thanks!Coruscation
I would change view !== undefined to typeof view !== 'undefined' as this could still result in an error.Presley
M
5

Roy Toledo answer works quite well for me, but i've replaced code in:

Divi/et-pagebuilder/js/admin.js

Divi version: 2.3.2

WP version: 4.7.1

Magnetics answered 20/1, 2017 at 17:53 Comment(0)
F
3

I had a similar problem with the Divi theme (2.6) and WP (4.5). Same error message. An upgrade of the theme to the latest (2.7.3) fixed it in my case. The latest version of the Extra theme is 1.3.4 - looks like you are on 1.2.4.4

Fayina answered 16/4, 2016 at 4:5 Comment(2)
I see.. The problem with me is that I don't have the updated version. :(Genarogendarme
for those that don't have a current ET subscription, in the spirit of Divi's GPL license, you can find a fix on github for version 2.3.4 (the security patched version) that works with WordPress 4.5Letsou

© 2022 - 2024 — McMap. All rights reserved.