Jump to content

IPS utility jquery issue

Featured Replies

Posted

Hi,

I use 

ips.ui.alert.show({type:'alert', icon:'warn', message: formattedMessage});

To show a warning message. In 40-50% of all cases it works fine, the other times it prints a javascript error in my console.log:

 

jquery.js?v=4409548e1d:3 Uncaught TypeError: Cannot read property 'style' of undefined at Sa (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:3:27454) at Function.css (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:3:30895) at La (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:3:24665) at Ma (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:3:24749) at cb (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:3:28868) at n.fn.init.show (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:4:578) at n.fn.init.n.fn.(anonymous function) [as show] (http://***.com/dev/js/library/jquery/jquery.js?v=4409548e1d:4:7543) at anim (http:/***.com/dev/js/framework/common/utils/ips.utils.anim.js?v=4409548e1d:168:9) at _checkQueue (http://***.com/dev/js/framework/common/utils/ips.utils.anim.js?v=4409548e1d:354:47) at http://***.com/dev/js/framework/common/utils/ips.utils.anim.js?v=4409548e1d:298:5

I am calling the ips.ui.alert.show() from a function inside of a javascript module:

var printWarning = function(data) {
  console.log(data);
  var socket = data.Socket;
  var message = data.Message;
  var url = socket.url;
  var formattedMessage = "[" + url + "] reported: " + message;
  ips.ui.alert.show({type:'alert',icon:'warn',message: formattedMessage});
};

Is that some kind of race condition against the jquery initialization? If so how could I prevent it.

Is this a javascript module within our framework, or are you loading the javascript file in some other manner?

Generally with jquery you do something along the lines of

$( document ).ready(function() {
	// Your code here
});

 

  • Author
7 hours ago, bfarber said:

Is this a javascript module within our framework, or are you loading the javascript file in some other manner?

Generally with jquery you do something along the lines of


$( document ).ready(function() {
	// Your code here
});

 

That's a function within a IPS.createModule function

Then it should execute only after the page has loaded already. Unfortunately with the information provided I'm unsure why you're seeing an error right now.

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.