Hello, I’m using the JColorBox extension from time ago (but the problem is extended in general to all widgets or extensions). Last day I I did changed the resources location to load from a CDN instead of typical “assets”:
/** ORIGINAL CODE **/
if($this->cssFile == NULL)
$this->cssFile = $this->scriptUrl.'/colorbox.css';
if($this->scriptFile == NULL)
$this->scriptFile = $this->scriptUrl . (YII_DEBUG ? '/js/jquery.colorbox.js' : '/js/jquery.colorbox-min.js');
/** DONT USE BECAUSE IN AJAX CALLS IT IS NOT RENDERED INSIDE THE HTTP REQUEST SO IT FAILS**/
/*if($this->cssFile == NULL)
$this->cssFile = "https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.4.3/$this->theme/colorbox.css";
if($this->scriptFile == NULL)
$this->scriptFile = YII_DEBUG ? 'https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.4.3/jquery.colorbox.js' : '//cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.4.3/jquery.colorbox-min.js';*/
There is no problem using the widget in a http standard request, but the problem is whenever I use the widget in an Ajax request, the "colorbox.js" library is loading by http request from CDN so its not ready to use at the moment of implement the $.colorbox() call so the page throws an error.
To clarify a little bit, I did a couple of screenshots:
Loading the colorbox.js library directly from assets, appear inside the XMLHttprequest:
Screenshot1
Loading the colorbox.js from CDN apper outside the XMLHttprequest, in fact appear in "scripts" tabs, so I think that is the problem:
Screenshot2
I tried to use the POS_READY position but the problem not seems to be related with jquery ready, it seems more related to load resources from external site, does it make sense?
Any solution on this?
thanks