google-code-export / zfdebug

Automatically exported from code.google.com/p/zfdebug
Other
1 stars 1 forks source link

Cannot execute jQuery functions before loading.. #53

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. just enable the firebug in firefox
2. reload the page with zfdebug enabled.

Firebug gives javascript error saying:
<code>
jQuery is not defined
828()828 (line 63)
[Break On This Error] jQuery.noConflict(); 
</code>

I'm using zfdebug 1.5.4 version

I suggest to change the code as follow.

Move the function call jQuery.noConflict(); in the beginning JavaScript loading 
into window.onload function.

                if (typeof jQuery == "undefined") {
                    var scriptObj = document.createElement("script");
                    scriptObj.src = "'.$this->_options['jquery_path'].'";
                    scriptObj.type = "text/javascript";
                    var head=document.getElementsByTagName("head")[0];
                    head.insertBefore(scriptObj,head.firstChild);
                    jQuery.noConflict();
                }

                var ZFDebugLoad = window.onload;
                window.onload = function(){
                    if (ZFDebugLoad) {
                        ZFDebugLoad();
                    }
                    ZFDebugCollapsed();
                };

Original issue reported on code.google.com by aruna.la...@gmail.com on 15 Jun 2010 at 7:38

GoogleCodeExporter commented 9 years ago
                if (typeof jQuery == "undefined") {
                    var scriptObj = document.createElement("script");
                    scriptObj.src = "'.$this->_options['jquery_path'].'";
                    scriptObj.type = "text/javascript";
                    var head=document.getElementsByTagName("head")[0];
                    head.insertBefore(scriptObj,head.firstChild);
                }

                var ZFDebugLoad = window.onload;
                window.onload = function(){
                    jQuery.noConflict();
                    if (ZFDebugLoad) {
                        ZFDebugLoad();
                    }
                    ZFDebugCollapsed();
                };

Original comment by aruna.la...@gmail.com on 15 Jun 2010 at 7:41

GoogleCodeExporter commented 9 years ago
I suggest when options set jquery_path to false not to use this code loader at 
all.
Any way ZFDebug injects jquery check BEFORE other scripts can be loaded and my 
jquery too.

Ie in my output html i has if (typeof jQuery == "undefined") { BEFORE <link 
rel="stylesheet" 
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery
-ui.css" type="text/css" />. So on, you need to disable jquery check if 
jquery_path set to null or false, or move your script BELOW all <head> scripts. 
Inject it into </head>, not into <head>. Thanks.

Original comment by dm.barsu...@gmail.com on 1 Dec 2011 at 4:10