I'm getting an 'undefined' in ie8 in th viewModel.js - any ideas?

132 views
Skip to first unread message

Daniel Whittaker

unread,
Mar 6, 2013, 11:20:06 AM3/6/13
to duran...@googlegroups.com
Hi All,

Just been trying out my new app in ie8 and it falls over and stops at the splash screen. The error is: 

Line: 54
Error: 'undefined' is null or not an object

And for context the actual code is:

createView: function(viewId) {
            var that = this;
            var requirePath = this.convertViewIdToRequirePath(viewId);
           
            return system.defer(function(dfd) {
                system.acquire(requirePath).then(function(markup) {
                    var element = that.parseMarkup(markup);
                        element.setAttribute('data-view', viewId); <<<<< This is 54 and the line ie8 is complaining about.
                        dfd.resolve(element);
                });
            }).promise();
        }

Daniel Whittaker

unread,
Mar 6, 2013, 11:25:02 AM3/6/13
to duran...@googlegroups.com
Forgot to mention, that error is on line 54 of the viewEngine.js file in the drunandal app folder.

Kingsley Hendrickse

unread,
Apr 3, 2014, 11:18:53 AM4/3/14
to duran...@googlegroups.com
Hi

I have the same issue in IE8 - (undefined is null or not an object) but with line 132 in viewEngine.js - the code seems to be the same though:

has anyone found a solution for this?

       createView: function(viewId) {
            var that = this;
            var requirePath = this.convertViewIdToRequirePath(viewId);

            return system.defer(function(dfd) {
                system.acquire(requirePath).then(function(markup) {
                    var element = that.processMarkup(markup);
 line 132 -->                   element.setAttribute('data-view', viewId);
                    dfd.resolve(element);
                }).fail(function(err){
                        that.createFallbackView(viewId, requirePath, err).then(function(element){
                            element.setAttribute('data-view', viewId);
                            dfd.resolve(element);
                        });
                    });
            }).promise();
        },

On Wednesday, 6 March 2013 16:20:06 UTC, Daniel Whittaker wrote:

discodi...@gmail.com

unread,
Jul 13, 2015, 7:10:22 PM7/13/15
to duran...@googlegroups.com
same error with line 165 now:
element.setAttribute('data-view', viewId);

still same code. Did noone ever find out why that is? :D

Garry Taylor

unread,
Jul 14, 2015, 4:57:04 AM7/14/15
to duran...@googlegroups.com
Is this happening in any other version of IE?

Garry Taylor

unread,
Jul 14, 2015, 11:43:38 AM7/14/15
to duran...@googlegroups.com
Just looking into this and I have found the following. Note I have not been able to confirm this yet as I don't have a VM with IE8 on and Windows 10 Emulator an't what it could be :)

I found this...
--------------------------------------------------------------------------------------
Looks like IE8 has issues with the setAttribute method.

To solve try the following:

Use this as your doctype
<!DOCTYPE html>

and then put this in the head of the document
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
--------------------------------------------------------------------------------------

Let me know how you get on..
PS IE8.. really :)

discodi...@gmail.com

unread,
Jul 14, 2015, 10:56:29 PM7/14/15
to duran...@googlegroups.com
It wasn't the doctype, actually.

see: http://stackoverflow.com/a/31420709/2064473
I found the mistake and it was not part of any javascript code.
the $.parseHTML() function in Durandals viewEngine.js only returns an object if the html markup supplied has syntactical correct HTML tags. I forgot to close one div at the very end of the view and that was the problem.

So, check the corresponding view for any missing html tags. This might solve your problem.
Reply all
Reply to author
Forward
0 new messages